fast-xml-parser
Advanced tools
Comparing version 4.0.6 to 4.0.7
Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library. | ||
**4.0.7 / 2022-03-18** | ||
* support CDATA even if tag order is not preserved | ||
* support Comments even if tag order is not preserved | ||
* fix #446: XMLbuilder should not indent XML declaration | ||
**4.0.6 / 2022-03-08** | ||
@@ -4,0 +9,0 @@ * fix: call tagValueProcessor only once for array items |
{ | ||
"name": "fast-xml-parser", | ||
"version": "4.0.6", | ||
"version": "4.0.7", | ||
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries", | ||
@@ -5,0 +5,0 @@ "main": "./src/fxp.js", |
@@ -21,2 +21,4 @@ # [fast-xml-parser](https://www.npmjs.com/package/fast-xml-parser) | ||
>Want to focus more on opensource, further study, and family. So open for part-time good job in technical architect, node js backend developer, research assistant, or IT teacher. https://amitkumargupta.work/ | ||
[![](static/img/ni_ads_ads.gif)](https://github.com/NaturalIntelligence/ads/) | ||
@@ -23,0 +25,0 @@ ## Users |
@@ -175,8 +175,7 @@ 'use strict'; | ||
if (attrStr && val.indexOf('<') === -1) { | ||
return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp ); | ||
} else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) { | ||
return this.indentate(level) + `<!--${val}-->` + this.newLine; | ||
}else { | ||
return ( | ||
this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + | ||
val + | ||
tagEndExp ); | ||
} else { | ||
return ( | ||
this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar + | ||
@@ -198,16 +197,23 @@ val + | ||
function buildTextValNode(val, key, attrStr, level) { | ||
let textValue = this.options.tagValueProcessor(key, val); | ||
textValue = this.replaceEntitiesValue(textValue); | ||
if (this.options.cdataPropName !== false && key === this.options.cdataPropName) { | ||
return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine; | ||
}else if (this.options.commentPropName !== false && key === this.options.commentPropName) { | ||
return this.indentate(level) + `<!--${val}-->` + this.newLine; | ||
}else{ | ||
let textValue = this.options.tagValueProcessor(key, val); | ||
textValue = this.replaceEntitiesValue(textValue); | ||
if( textValue === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired | ||
if(this.options.suppressUnpairedNode){ | ||
return this.indentate(level) + '<' + key + this.tagEndChar; | ||
}else{ | ||
return this.indentate(level) + '<' + key + "/" + this.tagEndChar; | ||
} | ||
} else{ | ||
return ( | ||
this.indentate(level) + '<' + key + attrStr + '>' + | ||
textValue + | ||
'</' + key + this.tagEndChar ); | ||
} | ||
if( textValue === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired | ||
if(this.options.suppressUnpairedNode){ | ||
return this.indentate(level) + '<' + key + this.tagEndChar; | ||
}else{ | ||
return this.indentate(level) + '<' + key + "/" + this.tagEndChar; | ||
} | ||
}else{ | ||
return ( | ||
this.indentate(level) + '<' + key + attrStr + '>' + | ||
textValue + | ||
'</' + key + this.tagEndChar ); | ||
} | ||
@@ -214,0 +220,0 @@ } |
@@ -44,3 +44,6 @@ const EOL = "\n"; | ||
const attStr = attr_to_str(tagObj[":@"], options); | ||
xmlStr += indentation + `<${tagName} ${tagObj[tagName][0][options.textNodeName]} ${attStr}?>`; | ||
const tempInd = tagName === "?xml" ? "" : indentation; | ||
let piTextNodeName = tagObj[tagName][0][options.textNodeName]; | ||
piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : ""; //remove extra spacing | ||
xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr}?>`; | ||
continue; | ||
@@ -47,0 +50,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94876
1791
192