Closed mdeknowis closed 1 year ago
I'm glad you find this repository helpful. I'll try to address your issue ASAP. You can watch the repo for new changes or star it.
What I can understand here is format issue. This is not in the development plan for ordered parse response yet. However, PR is welcome.
This formatting change only occurs, if preserveOrder is enabled. Also only for non-comment tags.
I guess, it might be caused by src\xmlbuilder\orderedJs2Xml.js
:
function arrToStr(arr, options, jPath, level){
let xmlStr = "";
let indentation = "";
if(options.format && options.indentBy.length > 0){//TODO: this logic can be avoided for each call
indentation = EOL + "" + options.indentBy.repeat(level);
}
// ...
if(tagName === options.textNodeName){
let tagText = tagObj[tagName];
if(!isStopNode(newJPath, options)){
tagText = options.tagValueProcessor( tagName, tagText);
tagText = replaceEntitiesValue(tagText, options);
}
xmlStr += indentation + tagText; // <--- Here might be the root cause. Let's check, how to avoid that part and improve it
continue;
//...
Yes. there are 2 separate codes for prserved order parsed output and pretty output
I hope this is not issue anymore. Please reopen if it is not the case
Description
If I use preserveOrder my xml nodes get spreaded. This behaviour can be reproduced also using https://naturalintelligence.github.io/fast-xml-parser/
Input
I parse a XML like this
and as I use the builder all tags a spreaded like that
Without preserveOrder this is not happing, but I need the correct order, as I try to manipulate the XML and have to keep the comments at the correct place
Code
Output
expected data