Submitted by admin on Fri, 09/02/2016 - 10:37
XML stands for Extensible Markup Language, which is used for businesses to data in electronic format. Unlike html, there are no predefined tags in XML. XML lets users to define their on tags to describe their data. Say, a user wants to create a shopping list. She can create her own tags. She can use the tag name <list> to describe the list. Then use the tag <item> to describe each item. For each item, she can use the tag <name> to describe name and <qty> to describe quantity.
So the XML looks like this:
<?xml version="1.0"?>
<list>
<item>
<name>Noodles</name>
<qty>3</qty>
</item>
<item>
<name>Sugar</name>
<qty>1lb</qty>
</item>
</list>
If a user wants to use the tag, <quantity> instead of <qty>, she is free to do so as there are no predefined tags in XML. It is up to the user to decide what each tag name means. If you have noticed the line, <?xml version="1.0"?>, that is the standard declaration line in all xml files.
XML Syntax
All XML files should follow the following syntax rules:
- The XML file should have exactly one root element that contains all xml. In the above example, root element is <list>, which contains everything else.
- All tags must be closed. (e.g., <name> should be followed by </name>)
- No overlapping tags. All tags must be correctly nested. <name> </name> <qty> </qty> is fine where as <name> <qty> </name> </qty> is not as the tags are overlapping. <name> <qty> </qty> </name> is fine syntactically as well although it probably doesn't make much sense in the above context.
- Tag name cannot contain spaces. Tag name should begin with an alphabet or _ character. Tag names are case sensitive.
- All attributes should be within double quotes (" ").
- The declaration line should be the very first in an XML file.