Parsing of XML files in CDM

  • Release version: Yokohama
  • Updated January 30, 2025
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Parsing of XML files in CDM

    The CDM XML parser in ServiceNow enables the efficient parsing of attribute key-value pairs from XML files into JSON format when importing configuration data into the Configuration Data Management (CDM) application. This capability helps users clearly distinguish attributes from configuration data items within the CDM editor and list views, simplifying data management and validation during import and export processes.

    Show full answer Show less

    Note that starting with the Washington DC release, DevOps Config is being prepared for deprecation, meaning it will no longer be installed on new instances but will continue to be supported.

    Key Features

    • XML to JSON Conversion: When uploading XML config files, the parser converts XML attributes to JSON keys prefixed with @ and enclosing text to a #text key if both attributes and text are present. This preserves the structure and attribute information in JSON format.
    • JSON to XML Conversion: For exporting config data back to XML, users must ensure attribute keys are prefixed with @ and text values are assigned to #text keys to maintain the original XML structure with attributes and enclosing text.
    • Improved Data Identification: The prefixing system allows easy identification and differentiation of attributes versus element values within the CDM editor panel and list views.
    • Validation Support: The parser supports validating imported CSV data with attributes during deployment by maintaining attribute integrity in the config data.

    Practical Application for ServiceNow Customers

    When importing XML configuration data into CDM, expect the parser to automatically convert XML attributes and text into a clear JSON representation, which simplifies editing and validation. This allows for accurate management of configuration items with attributes directly inside ServiceNow.

    When exporting configuration data to XML, ensure attributes and text are correctly labeled with @ and #text prefixes in your JSON data to preserve the intended XML structure, supporting smooth round-trip data handling.

    This functionality supports customers in migrating and maintaining configuration data across formats without losing attribute details, improving data consistency and operational efficiency in configuration management workflows.

    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.

    Important:
    Starting with the Washington DC release, DevOps Config is being prepared for future deprecation. It will be hidden and no longer installed on new instances but will continue to be supported. For details, see the Deprecation Process [KB0867184] article in the Now Support Knowledge Base.
    This parsing of attribute key-value pairs from an XML file to a JSON format in CDM helps you in the following ways:
    • 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

    When you import an XML file to upload your config data into CDM, the parser converts attributes and enclosing text in XML elements to the JSON format as follows:
    • 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.
    These options help in identifying attributes and enclosing text in the Editor panel and List view while reviewing the config data.
    The following example shows how the conversion looks between XML and JSON formats:
    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

    To keep the XML attributes and enclosing text in their original format when exporting the config data to an XML file format, you must update the config data as follows:
    • 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.