JSON - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

JSON Vs XML

JSON Vs XML

shape Description

XML stays for eXtensible Markup Language, XML came into picture to transport the information and to store the information. Numerous people will envision that XML is a substitution of HTML, in any case it was arranged exceptionally to pass on the information not to reveal the information like HTML while developing any web applications by using servlets or JSP by and large XML will be used to pass on the data. The essential point is that it is not a vernacular and stage free, the customer can use have names in XML.

shape Example

Following is an example for XML. [html] <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>User</to> <from>Splesson</from> <heading>Reminder</heading> <body>Please register to the site</body> </note> [/html] Where first line is the declaration of the XML code, is the root of the code.

shape Conceptual Figure

Following is an example structure image for XML.

Syntatic Rules for XML

shape Description

Following are the syntax rules for XML language.

XML Declaration

The following is the basic syntax declaration of XML document. [xml]<?xml version="1.0" encoding="UTF-8"?>[/xml] Where rendition is only XML form and encoding is utilized to indicate the character encoding. XML is case delicate, it ought to start with "" where "xml" ought to be in lower-case.

Tags and Elements

The following is the basic syntax declaration of XML document. [xml]<element>[/xml] The XML document will have several sub-elements, these elements need to start with and has to be end with .

XML Attributes

These attributes are used to provide a link, the following is an example. [xml]<a href="http://www.splessons.com/">SPlessons!</a>[/xml] Where href is the attribute and http://www.splessons.com/ is the attribute value.

XML References

References ordinarily permit you to include or incorporate extra content or markup in an XML archive. References dependably start with the "&" ,which is a saved character and end with the ";". XML will have two sorts of references such as Entity References, Character References.

XML Text

As discussed above XML is a case sensitive in attributes and elements, UTF-8 or UTF-16 files are used to avoid the problems with character encoding, whitespace characters will be ignored while writing elements.

Advantages Of XML

shape Description

Following are the some advantages or features of XML language.

Simplifies data sharing

JSON Vs XML - The major advantage of XML is that data will be stored in plain text format so any particular software and hardware's are not required then data will be shared easily through various applications.

Simplifies data transport

Share the data through the internet is always time taking the process for developers, but in XML data will be stored in plain text format and readability also easy with an incompatible application.

Simplifies Platform change

Changing the operating system from one version to another version process will take a lot of system resources such as memory, RAM, etc. XML data will be stored in plain text format so while upgrading version of operating system data will not be lost.

Increases data availability

XML information will be available to other all reading machines such as voice machines, news feeds, etc.

Creation of new languages

By using XML languages, it will be very easy to create internet languages such as XHTML, SMIL, etc.

Difference Between JSON and XML

shape Description

There are lot of differences between JSON and XML such as follows.
JSON XML
JSON abbreviation is that JavaScript Object Notation. XML abbreviation is that eXtensible Markup Language.
Easy to read and write XML is less easy to read and write than JSON.
Learning is very easy. Learning is not easy compared to JSON.
It is a data oriented. It is a document oriented.
It supports arrays. It does not support arrays.
Does not have expose capabilities. It provides capabilities to expose the data.
Secure less. More secure.
Data is human readable format. Data is less human readable format.
The text and number data types will be supported. It supports all data types such as image, graph, number, etc.

Code comparison Between JSON And XML

shape Example

Following is an example for JSON. [html] {"employees":[ {"name":"Sachin", "email":"sachin@gmail.com"}, {"name":"Dhoni", "email":"dhoni@gmail.com"}, {"name":"Smith", "email":"smith@gmail.com"} ]} [/html] Following is an example of XML by using above code. [html] <employees> <employee> <name>Sachin</name> <email>sachin@gmail.com</email> </employee> <employee> <name>Dhoni</name> <email>dhoni@gmail.com</email> </employee> <employee> <name>Smith</name> <email>smith@gmail.com</email> </employee> </employees> [/html] JSON Vs XML - So the final conclusion is that JSON is used to reduce the length of the code.

Summary

shape Key Points

  • JSON Vs XML - XML and JSON both are platform independent languages.
  • JSON Vs XML - XML was completely developed for intention of carrying data, but not to display.
  • JSON Vs XML - Both JSON and XML are self describing.