Parsing of XML files in CDM
Summarize
Summary of Parsing of XML files in CDM
The CDM XML parser in the Zurich release enables ServiceNow customers to efficiently parse attribute key-value pairs from XML files when uploading configuration data into the Common Data Model (CDM). This functionality allows attributes of XML elements to be clearly identified and managed within the CDM editor or list view, improving visibility and validation of configuration data. Note that DevOps Config is deprecated and not supported for new activations.
Show less
Key Features
- Converts XML attributes and element text into JSON format upon import, using an @ prefix for attributes and a #text key for element text when both are present.
- Facilitates easy differentiation of attributes from other configuration data items in CDM views.
- Ensures validation of imported CSV data with attributes is compatible with CDM deployment processes.
- Supports exporting configuration data back to XML by requiring the @ prefix and #text keys in JSON to preserve attribute and text structure in the XML output.
Practical Use
When importing XML configuration files, attributes are automatically converted to JSON key-value pairs with an @ prefix, and element text is stored under #text if both attributes and text coexist. For example, an XML element with attributes and text:
<provider region="EMEA">ABCPay</provider>
is represented in JSON as:
"provider": { "@region": "EMEA", "#text": "ABCPay"}
Similarly, when exporting data back to XML, JSON keys with @ and #text are used to reconstruct the original XML attributes and text content correctly.
Next Steps
- Ensure that when preparing JSON data for export to XML, attribute keys are prefixed with @ and text content keys are named #text as needed.
- Use the CDM editor and list views to review and validate attribute data after import.
- Refer to related processes like uploading config data and parsing CSV files in CDM for comprehensive configuration management.
- Add the necessary nodes containing configuration data to your CDM application to enable smooth data handling.
The CDM XML parser enables the parsing of attribute key-value pairs in XML files, so when you upload config data from an XML file into CDM, you can easily identify the attributes of each element in the CDM editor or list view.
- Uploading existing config data from an XML file, including the attributes of XML elements as appropriate key-value pairs in JSON.
- Differentiating attributes from the config data items easily in the CDM editor.
- Validating imported CSV data with attributes in CDM for deployment.
- Converting attribute key-value pairs in JSON format as XML element attributes in XML file.
Parsing of XML to JSON during import
- Adds the @ prefix to all key names corresponding to attributes of XML elements.
- Adds a #text key for the enclosing text value of XML elements that have both attributes and enclosing text.
- XML format
<app> <components> <paymentService type="B2C"> <provider region="EMEA">ABCPay</provider> <service>XYZPay</service> </paymentService> </components> <app>- JSON format
{ "app" : { "components" : { "paymentService" : { //key-value pair for XML elements with attributes "@type" : "B2C", // @ prefix for attribute "provider" : { "@region" : "EMEA", // @ prefix to key name for attribute "#text" : "ABCPay" // #text key name for enclosing text }, "service" : "XYZPay" //key-value pair for XML elements without attributes } } } }
Parsing of JSON to XML during export
- Add the @ prefix to all key names to make them parse as attributes of XML elements.
- Add keys named #text to CDIs that should be parsed as the enclosing text value of XML elements, when both attributes and enclosing text are present.