Overview

This function converts an XML string to an object. By converting XML to an object, you will be able to leverage many of the built in functions such as those in the list and object categories to process and utilize values from the XML string throughout the rest of your Flow.

Input Fields

  • xml (text): the XML string to be converted into an object
  • options
    • attrkey (text) - default is ‘$’: The string to use as the key for the attribute object created for each XML element.
    • charkey (text) - default is ‘_’:The string to use as the key to access character content within an XML element. This only applies if ‘explicitCharkey’ is ‘true’. In the example included below, this would change the output to something like the following for an element: "artist": [ { "_": "Surfer Blood" } ]
    • explicitCharkey (true/false) - default is false: Designates if the ‘charKey’ specified above is used. If false, output will look like the example below; if true, output will look like the snippet above.
    • trim (true/false) - default is false: Designates if the whitespace at the beginning and end of a text node should be removed. If true, the content 'Surfer Blood    ' in the input XML would become 'Surfer Blood' in the output object.
    • normalizeTags (true/false) - default is false: Designates if all tag names should be normalized to lowercase. If true, ‘<ARTIST>' in the input XML would become ‘artist’ in the output object.
    • normalize (true/false) - default is false: Designates if whitespace within a text node should be trimmed.
    • explicitRoot (true/false) - default is false: Designates if the root node should be included in the resulting object. If true, the below example output would be wrapped within a ‘catalog’ object.

Output Fields

  • output (object): an object constructed based on the input XML and selected options

Example XML Input

<?xml version="1.0"?>
<catalog>
  <release id="JNR165.8">
    <artist>Surfer Blood</artist>
    <title>1000 Palms</title>
    <genre>Rock</genre>
    <label>Joyful Noise Recordings</label>
    <release_date>2015-05-12</release_date>
  </release>
  <release id="OLE 984-7">
    <artist>The Men</artist>
    <title>Singles Going Home Alone #3</title>
    <genre>Rock</genre>
    <label>Matador Records</label>
    <release_date>2012-03-01</release_date>
  </release>
  <release id="SC007">
    <artist>Michael Nau</artist>
    <title>Love Survive</title>
    <genre>Rock</genre>
    <label>Singles Club</label>
    <release_date>2015-09-01</release_date>
  </release>
  <release id="DEG001">
    <artist>Coastal</artist>
    <title>Winter</title>
    <genre>Rock</genre>
    <label>Dream by Degrees</label>
    <release_date>2002-01-01</release_date>
  </release>
</catalog>

Example Object Output (based on default selections)

{ 
  "release": [ 
    { 
      "$": { "id": "JNR165.8" },
      "artist": [ "Surfer Blood" ],
      "title": [ "1000 Palms" ],
      "genre": [ "Rock" ],
      "label": [ "Joyful Noise Recordings" ],
      "release_date": [ "2015-05-12" ]
    }, 
    { 
      "$": { "id": "OLE 984-7" },
      "artist": [ "The Men" ],
      "title": [ "Singles Going Home Alone #3" ],
      "genre": [ "Rock" ],
      "label": [ "Matador Records" ],
      "release_date": [ "2012-03-01" ] 
    }, 
    { 
      "$": { "id": "SC007" },
      "artist": [ "Michael Nau" ],
      "title": [ "Love Survive" ],
      "genre": [ "Rock" ],
      "label": [ "Singles Club" ],
      "release_date": [ "2015-09-01" ]
    }, 
    { 
      "$": { "id": "DEG001" },
      "artist": [ "Coastal" ],
      "title": [ "Winter" ],
      "genre": [ "Rock" ],
      "label": [ "Rock" ],
      "release_date": [ "2002-01-01" ] 
    } 
  ] 
  }