Welcome to the great environment of XML (Extensible Markup Language). This xml tutorial is going to help specially for beginners to understand few important things about XML world.
What is XML?
XML (Extensible Markup Language) is highly used to exchange data in internet world. You may exchange data within system or with different system the way you want. That means, when it come to transferring well structured data from server to client, server to another server or system to system, XML is an ideal solution to do that.
For the most web standard, W3.org is responsible for development and maintenance purpose. W3C, they have defined and developed this standard which is similar like HTML.
Let’s look more inside about how XML document does looks with its standard.
<?xml version="1.0" encoding="UTF-8"?>
<products>
<product>
<name>Sony Xperia R1 Dual</name>
<color>Silver</color>
<price>$650.00</price>
<discount>$20.00</discount>
</product>
</products>
Now, let’s save this as xml document and see how it looks in browser. To save this, you need to use “.xml” as an extension to save your xml file. This is mandatory to store like that otherwise an application or system won’t recognize its xml document.
The browser will use “MSXML” with its default CSS(Stylesheet) and display xml file details in a tree structure as above.
Structure of XML document
An XML document create by the help of two section as following
Prolog
Body
It defines all the data and elements in xml as hierarchical structure. The xml document will start with “Prolog” which is optional. This section also called declaration part of the xml document. Rest of the part in xml document called “Body” part. Body part actually consists of data, elements and attributes with hierarchical structure.
Let’s understand the syntax for both parts.
Syntax for “Prolog” declaration part
<?xml version="1.0" encoding="UTF-8"?>
Syntax for “Body” part
<products>
<product>
<name>Sony Xperia R1 Dual</name>
<color>Silver</color>
<price>$650.00</price>
<discount>$20.00</discount>
</product>
</products>
So, if we follow above format to create xml document, we can say it’s well formatted xml document. XML document is valid document If it’s well formatted and also refer to DTD (Data Type Definition).
Parsers
Alright, in above section we learn about how to create xml document, how to store it with its hierarchical structure. Now, it’s time to read the xml document or manipulate that in such a way where you use it into your application. To do that, it’s called “XML Parser”.
XML Parser provides a way where you can read and manipulate xml document to an application. It’s also known as “XML Processors” which provide with standard API to read and manipulate your xml document.
DOM is one of them to provide an easy way where you can read your xml and modify its data easily. But, if you have larger xml document, it won’t help because it store it into memory because it load whole xml file into memory and consume resources.
Another is ASX which is also called Simple API for xml. This is completely depends on events based model. This works different than DOM, it doesn’t load whole document into memory, instead that, it load document sequentially into memory and send that into application with an events.
Note: There are many other tools available online to use them as XML parsers and you can easily navigate or modify your xml documents.
Finally, in short summary here
In this section “xml tutorials”, we learn about basic of XML, xml documents and its structures, what information you can store in document, how xml define its structure with Prolog and Body parts, sample xml document and how you can parse your xml document by using different xml parsers.















