XML
Purpose
Section titled “Purpose”The XML Operator enables working with XML (eXtensible Markup Language) files. It provides functionality for converting data to XML format and parsing XML content into structured data.
Use Cases
Section titled “Use Cases”- Converting object data to XML format
- Parsing XML files into structured data
- Integrating with systems that use XML for data exchange
- Processing configuration files in XML format
- Working with XML-based APIs
- Data transformation between XML and other formats
- Generating XML reports or documents
Supported Operations
Section titled “Supported Operations”to-xml
Section titled “to-xml”Converts an input object to an XML file. Uses object fields/elements as XML elements.
Input Parameters
Section titled “Input Parameters”value
(Object): The data to convert to XML formatencoding
(string): The character encoding to use for the XML file
Output
Section titled “Output”Returns a FileDto object containing information about the created XML file, including:
id
(string): The unique identifier of the filename
(string): The file name (default is “data.xml”)contentType
(string): The content type (“application/xml”)size
(long): The file size in bytesorganizationId
(string): The organization ID associated with the file
Example
Section titled “Example”{ "value": { "customer": { "id": "12345", "name": "John Doe", "address": { "street": "123 Main St", "city": "Anytown", "zipCode": "12345" } }, "items": [ {"id": "item1", "name": "Product 1", "price": 19.99}, {"id": "item2", "name": "Product 2", "price": 29.99} ] }, "encoding": "UTF-8"}
from-xml
Section titled “from-xml”Reads a provided XML file and converts it to structured data.
Input Parameters
Section titled “Input Parameters”file
(FileDto): The XML file to readencoding
(string, optional): The character encoding of the file
Output
Section titled “Output”Returns a Map representing the XML data structure, with element names as keys and their content as values. Nested elements are represented as nested Maps.
Example
Section titled “Example”{ "file": { "id": "file-123", "organizationId": "org-456" }}
- The operator uses Jackson’s XmlMapper for XML parsing and generation
- XML elements are automatically wrapped in a root element if needed
- Complex objects are converted to XML elements with nested structure
- The XML parsing preserves the hierarchical structure of the original XML