jgradim / xml2json

XSLT Stylesheet to transform arbitrary XML to a JSON representation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xml2json

xml2json is an XSLT Stylesheet to transform arbitrary XML to a JSON representation

JSON Output

This projects aims to produce JSON documents from arbitrary, well-formed XML documents.

CHANGELOG

v1.2 – April 19th, 2010

Added support for elements with multiple children text nodes. Text nodes are now named $text1, $text2, etc if more than one sibling text node is present.

v1.1 – April 18th, 2010

Added support for same name, ungrouped elements. Ungrouped sibling elements with the same name are converted into JSON objects with an appended number representing their index (starting with 1). This allows the transformation to preserve the original structure of the document without any data loss.

Example:

<an-element />
<tag>a</tag>
<tag>b</tag>
<tag>c</tag>
<another-element />

is converted to

...
{"tag1":{"$text":"a"}},
{"tag2":{"$text":"b"}},
{"tag3":{"$text":"c"}}
...

v1.0 – April 17th, 2010

First functioning version of the stylesheet, with support for text processing as strings or numbers, arrays, and special characters escaping (\ and ")

About

XSLT Stylesheet to transform arbitrary XML to a JSON representation