Easy Tutorial
❮ Json Intro Json Tutorial ❯

JSON vs XML

Both JSON and XML are used to receive data from web servers.

JSON and XML differ in their syntax, as shown below:

JSON Example

{
    "sites": [
    { "name":"tutorialpro.org" , "url":"www.tutorialpro.org" }, 
    { "name":"google" , "url":"www.google.com" }, 
    { "name":"微博" , "url":"www.weibo.com" }
    ]
}

XML Example

<sites>
  <site>
    <name>tutorialpro.org</name> <url>www.tutorialpro.org</url>
  </site>
  <site>
    <name>google</name> <url>www.google.com</url>
  </site>
  <site>
    <name>微博</name> <url>www.weibo.com</url>
  </site>
</sites>

Similarities between JSON and XML:

The biggest difference is: XML requires an XML parser to parse, while JSON can be parsed using standard JavaScript functions.


Why is JSON Better Than XML?

XML is harder to parse than JSON.

JSON can directly use existing JavaScript objects for parsing.

For AJAX applications, JSON loads data faster and is simpler:

Using XML:

Using JSON:


Related Articles

❮ Json Intro Json Tutorial ❯