Transform XML fragments into JSON. The target of this module is to create a straight-forward Javasript representation of data-centric XML. It does not try to handle mixed content nodes (with a mix of elements and text).
The root element will be absorbed, i.e. <root>text</root> becomes "text".
Child elements with the same name are added to an array.
If an element has attribute and text content, the text content becomes a property, e.g. '#text': 'my text'.
In mixed content nodes, text nodes will be dropped.
An empty element becomes 'null', i.e. <e/> becomes {"e": null}.
An element with a single text child becomes a property with the value of the text child, i.e. <e>text</e> becomes {"e": "text"}
Helper function: output the contents of a node or attribute. Special cases:
An empty element becomes 'null', i.e. <e/> becomes {"e": null}.
An element with a single text child becomes a property with the value of the text child, i.e. <e>text</e> becomes {"e": "text"}
Module URI | Function Name |
---|---|
http://www.w3.org/2005/xpath-functions | concat |
count | |
string |
Module URI | Function Name |
---|---|
http://www.json.org | element-helper |
node-to-json |
Module URI | Function Name |
---|---|
http://www.json.org | node-to-json |
xml-to-json |
Helper function: output element content for elements with more than one child node or attribute. Special cases:
Child elements with the same name are added to an array.
If an element has attribute and text content, the text content becomes a property, e.g. '#text': 'my text'.
In mixed content nodes, text nodes will be dropped.
Module URI | Function Name |
---|---|
http://www.w3.org/2005/xpath-functions | concat |
distinct-values | |
node-name | |
string-join |
Module URI | Function Name |
---|---|
http://www.json.org | node-to-json |
Module URI | Function Name |
---|---|
http://www.json.org | contents-to-json |
Helper function: convert a node into JSON.
Module URI | Function Name |
---|---|
http://www.w3.org/2005/xpath-functions | concat |
node-name | |
string-join |
Module URI | Function Name |
---|---|
http://www.json.org | contents-to-json |
Module URI | Function Name |
---|---|
http://www.json.org | contents-to-json |
element-helper |
Main entry point of the module. Convert a single node into JSON. The root element will be absorbed.
Module URI | Function Name |
---|---|
http://www.json.org | contents-to-json |