XML Document
Parse an XML document into JSON items, or create an XML document from JSON items.
Revision History
0.0.0.4 - Initial release.
0.0.0.11 - Current release.
Setup Notes
- Use JSON object structure to represent XML elements, attributes, and text content when you create XML.
- For best results with
Create, prepare each item as a single JSON object whose only top-level property is the XML element you want to write.
Methods
Parse
Reads an XML document and returns JSON items based on the document structure.
If the source XML document has a root element that contains a homogeneous list of child elements, each child element is returnd as a separate line.
If the source XML document has mixed child element names, mixed content, or a single root object, the full root element is returned as a single item.
| Parameter | Type | Description |
|---|---|---|
Document |
Stream | The XML document to parse. |
| Return | Type | Description |
|---|---|---|
Items |
Array | JSON representation of the parsed XML content. |
Create
Writes JSON items to an XML document. All output items are wrapped in a top-level <Documents> element.
| Parameter | Type | Description |
|---|---|---|
Items |
Array | The XML items to serialize. Each item must be a JSON object that contains one root element. |
| Return | Type | Description |
|---|---|---|
Document |
Stream | The rendered XML document. |
Usage Notes
- XML attributes are represented with property names that start with
@. For example,@idbecomes an XML attribute namedid. - Text content can be represented with
#textwhen an element also has attributes or child elements. - Repeated child elements are returned as JSON arrays.
Known Issues
Createcannot create an element directly from a top-level JSON array. Provide each array item as a separate input item instead.