jindw / xmldom

A PURE JS W3C Standard based(XML DOM Level2 CORE) DOMParser and XMLSerializer.
Other
816 stars 265 forks source link

Adding config options for additional escaping of characters for text encoding #226

Open ashpurik opened 6 years ago

ashpurik commented 6 years ago

We are facing an issue where we need some additional escaping of characters for text encoding, such as apostrophes. I saw that some other PRs were opened for this issue and have not been merged. If I open a PR that includes a config option for additional character escaping, would that be more likely to be accepted?

Example fix for the serializeToString method in dom.js:

case TEXT_NODE:
     let rgxReplace = '\[<&';
     if (config) {
          rgxReplace += config;
     }
     rgxReplace += '\]';
     const re = new RegExp(rgxReplace, 'g');
     return buf.push(node.data.replace(re,_xmlEncoder));

where config could be something like: config = "'>";

Thanks!

amitguptagwl commented 5 years ago

This project is not active anymore. You can try fast-xml-parser instead