XML to JSON -- a converter
June 8, 2006
Update January 22, 2008:
You can also try it out here:
If you are running in a browser there are so many scripts out there today that do a better job. I recommend the one you can find at www.terracoder.com
How to use xml2json
To use xml2json you simply embed it in the head section of your web pages, before any other scripts that uses it.
Then you use the method xml2json.parser() to convert your XML:
// A simple call - myXML is a string containing your XML:
// A 2:nd, optional, parameter is "tags not to convert" - for example <b> and <i>:
// A 3:rd, optional, parameter gives us a string showing us the JSON structure
// instead of the actual JSON object:
// - use "compact" for output without linebreaks or tabbing
// - use "normal" for output with linebreaks and tabbing
// - use "html" for a html representation
When to use client side conversion?
Use the converter when you can see an advantage in client side conversion. For example this converter has been a part of the studentlitteratur.se search engine for some time now.
Are there others out there?