This library provides XML to JSON (JavaScript Objects) and vice versa javascript conversion functions. The library is very small and doesn't require any other additional libraries. Forked from https://code.google.com/p/x2js/
This results in xml-files that looks ugly like this:
...
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
...
The only characters that has to be escaped are: <, &, >, ", '
Also ' should be replaced with '
See:
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#En
tities_representing_special_characters_in_XHTML
Replacement code:
function escapeXmlChars(str) {
if(typeof(str) == "string")
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
else
return str;
}
Also the unescapeXmlChars should handle any escaped character (unicode and
named) and not a small predefined set.
Original issue reported on code.google.com by david.gr...@gmail.com on 5 Feb 2015 at 1:34
Original issue reported on code.google.com by
david.gr...@gmail.com
on 5 Feb 2015 at 1:34