XML-to-JSON Conversion Tool at onlinexmltools.com

This section provides a tutorial example on how to use an online XML-to-JSON conversion tool at onlinexmltools.com. The output JSON document is good, only if input XML document contains well structured data.

With the XML-to-JSON conversion sample provided in the previous tutorial, let's try an online conversion tool and see how it converts the sample XML document.

1. Go to "xml to json converter" Website at https://onlinexmltools.com/convert-xml-to-json.

2. Copy and paste our XML document sample, xml.html, to the "xml" area on the left.

<html>
<body bgcolor="#dddddd">
<h4>My XML Web Page</h4>
<p>A simple text paragraph.</p>
<p>A complex paragraph with <em>highlight text</em>, <br/>line breaks,
  <font color="#ff0000" size="+1">font changes</font>, etc.
</p>
</body>
</html>

3. Review the converted JSON document in the "json" area on the right:

{
  "body": {
    "h4": "My XML Web Page",
    "p": [
      "A simple text paragraph.",
      {
        "em": "highlight text",
        "br": "",
        "font": {
          "_color": "#ff0000",
          "_size": "+1",
          "__text": "font changes"
        },
        "__text": "A complex paragraph with \n, \nline breaks,\n  \n, etc."
      }
    ],
    "_bgcolor": "#dddddd"
  }
}

As you can see, this conversion tool uses some different conversion rules:

Obviously, this conversion tool does not preserve the structure of the sample XML document, which contains complex XML elements with multiple child text segments like HTML documents. You can not find any way to convert the JSON document generated above back to the original XML document.

However, if an XML document, products.xml, contains only structured data shown below, the output is pretty good.

Input XML: products.xml 
---------
<products>
 <available>
  <product>
   <name>pen blue</name>
   <count>22</count>
  </product>
  <product>
   <name>pen red</name>
   <count>17</count>
  </product>
  <product>
   <name>paper, letter</name>
   <count>50</count>
  </product>
 </available>
 <queued>
  <queue_delayed>
   <product>
    <name>colored pencils</name>
    <count>10</count>
   </product> 
  </queue_delayed>
  <queue_active>
   <product>
    <name>stapler</name>
    <count>15</count>
   </product> 
   <product>
    <name>document holder</name>
    <count>5</count>
   </product> 
  </queue_active>
 </queued>
</products>

Output JSON: products-online.json
-----------
{
  "available": {
    "product": [
      {
        "name": "pen blue",
        "count": "22"
      },
      {
        "name": "pen red",
        "count": "17"
      },
      {
        "name": "paper, letter",
        "count": "50"
      }
    ]
  },
  "queued": {
    "queue_delayed": {
      "product": {
        "name": "colored pencils",
        "count": "10"
      }
    },
    "queue_active": {
      "product": [
        {
          "name": "stapler",
          "count": "15"
        },
        {
          "name": "document holder",
          "count": "5"
        }
      ]
    }
  }
}

Table of Contents

 About This Book

 Introduction of XML (eXtensible Markup Language)

 XML File Syntax

 XML File Browsers

XML-JSON Document Conversion

 What Is JSON (JavaScript Object Notation)

 Convert XML Document to JSON Document

 XML-to-JSON Conversion Rules

XML-to-JSON Conversion Tool at onlinexmltools.com

 XML-to-JSON Conversion Library for Java

 XML-to-JSON Conversion Module for Python

 Convert JSON Document to XML Document

 JSON-to-XML Conversion Rules

 JSON-to-XML Conversion Tool at onlinexmltools.com

 JSON-to-XML Conversion Library for Java

 JSON-to-XML Conversion Module for Python

 DOM (Document Object Model) Programming Interface

 SAX (Simple API for XML) Programming Interface

 DTD (Document Type Definition) Introduction

 Syntaxes of DTD Statements

 Validating an XML Document against the Specified DTD Document Type

 XSD (XML Schema Definition) Introduction

 Syntaxes of XSD Statements

 Validating XML Documents Against Specified XML Schemas

 XSL (Extensible Stylesheet Language) Introduction

 XSLT (XSL Transformations) Introduction

 Java Implementation of XSLT

 XPath (XML Path) Language

 XSLT Elements as Programming Statements

 Control and Generate XML Element in the Result

 PHP Extensions for XML Manipulation

 XML Notepad - XML Editor

 XML Tools Plugin for Notepad++

 XML Plugin Packages for Atom Editor

 XML 1.1 Changes and Parsing Examples

 Outdated Tutorials

 References

 Full Version in PDF/EPUB