Validate XML or Parse XML to JS/JSON very fast without C/C++ based libraries and no callback
You can use this library online (press try me button above), or as command from CLI, or in your website, or in npm repo.
$npm install fast-xml-parser
or using yarn
$yarn add fast-xml-parser
var fastXmlParser = ;var jsonObj = fastXmlParser;// when a tag has attributesvar options =attrPrefix : "@_"textNodeName : "#text"ignoreNonTextNodeAttr : trueignoreTextNodeAttr : trueignoreNameSpace : truetextNodeConversion : true;iffastXmlParser=== true//optionalvar jsonObj = fastXmlParser;//Intermediate objvar tObj = fastXmlParser;var jsonObj = fastXmlParser;
To use from command line
$xml2js [-ns|-a] <filename> [-o outputfile.json]
To use it on webpage
var isValid = parser;var jsonObj = parser;
I decided to created this library when I couldn't find any library which can convert XML data to json without any callback and which is not based on any C/C++ library.
Libraries that I compared
Why not C/C++ based libraries? Installation of such libraries fails on some OS. You may require to install missing dependency manually.
Don't forget to check the performance report on comparejs.
validator benchmark: 21000 tps
Parser doesn't check if the XML is valid or not. If the XML is not valid you may get invalid result. So you can call the validator function first to check the structure.
Report an issue or request for a feature here
Give me a star, if you really like this project.
Fund collected (since the starting of the project) : $0
Some of my other NPM pojects