RapidIdentity Product Guide

XML to Record Mapping

For clarity, examples of the result records are shown as the would appear if resulting record were converted to JSON using toJSON(record, true).

Mapping Rules
  • Namespaces, namespace prefixes, comments, and processing instructions are all ignored.

  • Elements with no attributes and no content or whitespace-only content become null.

  • Elements with no subelements and no attributes become the text, numeric, or boolean value of the element content.

    <x>Hello</x>
    becomes
    "Hello"
  • Elements with attributes or child elements become a record

  • Nested element names (sans any namespace prefix) become record fields

    <x>
        <y>Hello</y>
    </x>
    becomes
    {
        "y": "Hello"
    }
  • Attributes become record fields prefixed with @

    <x>
        <y z="1"/>
    </x>
    becomes
    {
        "y": {
            "@z": 1
         }
    }
  • If an element has attributes and non-empty text only content, then the text content becomes a record field named value

    <x>
        <y z="1">Hello</y>
    </x>
    becomes
    {
        "y": {
            "@z": 1,
            "value": "Hello"
         }
    }
  • Multiple elements with the same name at the same level become multiple values of the same field.

    <x>
        <y>Hello</y>
        <y>Goodbye</y>
    </x>
    becomes
    {
        "y": ["Hello", "Goodbye"]
    }
  • If an element has mixed content (intermixed text and elements), then the text is ignored

    <x>
        <y>Hello</y>
         Something in between
        <y>Goodbye</y>
    </x>
    becomes
    {
        "y": ["Hello", "Goodbye"]
    }