Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • XML elements become JSON arrays
  • XML attributes becomes "$" object with fields
  • XML body text becomes "_" when there are attributes
  • All element names are flattened to lowercase
  • Attribute names are not flattened
XML posted to APIJSON in SchemaNote


Code Block
languagexml
themeEmacs
<xml/>



Code Block
languagejs
themeEmacs
{ 
  "xml" : "" 
}


An empty element produces an object with an empty field value. 


Code Block
languagexml
themeEmacs
<xml>
  <element/>
</xml>



Code Block
languagejs
themeEmacs
{ 
  "xml":  {  
     "element": [ "" ]  
   } 
}


An empty child element is turned into an array value with a single empty value. 


Code Block
languagexml
themeEmacs
<xml>
  <element>a</element>
  <element>b</element>
  <element>c</element>
</xml>



Code Block
languagejs
themeEmacs

{ 
  "xml": { 
    "element": [ "a", "b", "c" ] 
  }
}


A collection of child elements with simple values is transformed into an array of values. 


Code Block
languagexml
themeEmacs
<xml>
  <element attr1="a" attr2="b">first element</element>
  <element>second element</element>
  <element/>
</xml>



Code Block
languagejs
themeEmacs
{
    "xml": {
        "element": [
            {
                "$": {
                    "attr2": "b",
                    "attr1": "a"
                },
                "_": "first element"
            },
            "second element",
            ""
        ]
    }
}


A collection of child elements with attributes and simple or non-existent values are transformed to an array of objects.

Note that the attributes are held in the special "$" attribute of the object they refer to. 


Code Block
languagexml
themeEmacs
<xml>
  <element attr1="a" AttributeTwo="b">first element</element>
  <element>second element</element>
  <element/>
</xml>



Code Block
languagejs
themeEmacs
{
    "xml": {
        "element": [
            {
                "$": {
                    "AttributeTwo": "b",
                    "attr1": "a"
                },
                "_": "first element"
            },
            "second element",
            ""
        ]
    }
}


Similar to above but this demonstrates that the attribute names are not flattened. 


Code Block
languagexml
themeEmacs
<xml>
  <element attr1="a" attr2="b">first element</element2>
  <element>second element</element>
  <element/>
</xml>



Code Block
languagejs
themeEmacs
{
    "message": "Unexpected close tag\nLine: 1\nColumn: 55\nChar: >",
    "error": {}
}


Invalid XML leads to an error message which 

Kitewheel Hub Front-End Performance

...