Attribute value string not converted to HTML esc char by js2xml
vreshos opened this issue · 2 comments
vreshos commented
Using xml2js, read in an XML file with a node that has the following attribute:
src_text="& amp; (had to add a space for it to show up in the page)
When using js2xml to save the resulting object back to xml, I get the following output:
src_text="&"
Why isn't src_text value properly escaped with HTML esc character? This only happens when the attribute is a single '&' character. If there is other text, the & is escaped correctly
zhaoxiongfei commented
+1
zhaoxiongfei commented
js2xml(obj, {
attributeValueFn(v) {
return v.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
},
});
like this code, it work.