Tools, FAQ, Tutorials:
Mapping XML Simple Elements to JSON Values
What is the standard to map XML simple elements to JSON values?
✍: FYIcenter.com
There seems to be no industry standard on how to map XML simple elements to JSON values. 
But there are some commonly used conventions:
1. Converting each XML simple element to a single JSON object property. The property name is set to the element name and the property value is set to the element text content. For example:
XML:
<address>
  <street>21 2nd Street</street>
  <city>New York</city>
  <state>NY</state>
</address>
JSON:
{
  "address": {
    "street": "21 2nd Street",
    "city": "New York",
    "state": "NY"
  }
}
2. Converting empty XML elements to JSON properties with Null values. If the text content of an XML simple element is an empty string, it is converted to the JSON Null value. For example:
XML:
<address>
  <street>21 2nd Street</street>
  <city>New York</city>
  <county/>
  <state>NY</state>
</address>
JSON:
{
  "address": {
    "street": "21 2nd Street",
    "city": "New York",
    "county": null,
    "state": "NY"
  }
}
3. Converting each XML simple element with a single CDATA to a single JSON object property.. The property name is set to the element name and the property value is set to the CDATA content. For example:
XML:
<html><![CDATA[<hr><p>Hello World!<hr>]]></html>
JSON:
{
    "html": "<hr><p>Hello World!<hr>"
}
⇒ Mapping Repeating XML Elements to a JSON Array
2023-07-08, ∼1679🔥, 0💬
Popular Posts:
How to pull NVIDIA CUDA Docker Image with the "docker image pull nvidia/cuda" command? If you are ru...
What is Azure API Management Developer Portal? Azure API Management Developer Portal is an Azure Web...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...
What is EPUB 3.0 Metadata "dc:publisher" and "dc:rights" elements? EPUB 3.0 Metadata "dc:publisher" ...