XML Plus icon

XML Plus

Convert data to and from XML (community node)

XML to JSON

AI-generated

Overview

This node converts XML data to JSON format. It is useful when you need to parse XML content from an input property of incoming data items and transform it into a JSON object for easier manipulation and processing within workflows. For example, it can be used to convert XML responses from APIs or XML files into JSON for further automation steps.

Use Case Examples

  1. Converting an XML string stored in a property named 'data' into a JSON object stored in another property 'convertedData'.
  2. Parsing XML data from an incoming webhook payload and converting it to JSON for conditional logic or data extraction.

Properties

Name Meaning
Input Property The name of the property in the input JSON that contains the XML string to be converted to JSON.
Output Property The name of the property where the resulting JSON object will be stored after conversion.
Validator Whether to enable XML validation on the input XML data before conversion to ensure it is well-formed.
Validator Options Options to customize XML validation behavior, such as allowing boolean attributes or specifying unpaired tags.
Parser Options Options to customize how the XML is parsed into JSON, including attribute handling, text node naming, preserving order, and more.

Output

JSON

  • outputProperty - The JSON object resulting from the XML to JSON conversion, stored under the specified output property name.

Dependencies

  • fast-xml-parser library for XML parsing and validation

Troubleshooting

  • If the input property does not exist or is undefined, the node throws an error indicating the missing property.
  • If XML validation is enabled and the XML is invalid, the node throws an error with details about the XML validation failure.
  • Incorrect parser options may lead to unexpected JSON structure; verify parser options to match the XML format.
  • Ensure the input XML string is well-formed to avoid parsing errors.

Links

Discussion