Here is a sample XML document, xml.html, that we can use to validate our conversion rules. With a special the property name of "#n_text" where n is the index With in a complex XML content, a child text segment is converted as a JSON property With child element name as the property name prefixed with "$n_" where n is the indexħ. With in a complex XML content, a child element is converted as a JSON property Looping through the mix of child elements and text segments.Ħ. Prefixed with With in a complex XML element, convert element's content after attributes sequentially With in a complex XML element, convert element's attributes first sequentially.Įach attribute is converted as a JSON property with attribute's name as the property name For a complex XML element, its body, including attributes, child elements,Īnd text segments are converted as a JSON object.Ĥ. You may try to parse the element content as different JSON primitive types:ģ. If the XML document has XML Schema Instance types added, For a simple XML element, its content will be converted as a JSON primitive String value. The root element tag is used as the property name.Ģ. To record the root element tag, content, and attributes. Convert the XML root element as a JSON object with a single property Here is my suggestion to build a simple converter that preserves the original XML document structure.ġ. To implement own XML-to-JSON converter, you need define a set of conversion rules first. So that you have the full control of the output. If you are a developer, you may want to implement your own XML-to-JSON converter You can build your own converter with those rules. This section provides a simple set of XML-to-JSON Conversion Rules that preserves the structure of the original XML document. XML Tutorials - Herong's Tutorial Examples
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |