Syntax of XML-: The syntax rules are very easy in xml. These are very easy to learn and use . We know that in the xml document have a root elements that is the parent of all elements. There are some rules are define in the XML language these are the..
1. -: XML prolog-: When we writing a xml program then we write this code in our documents.
<?xml version="1.0" encoding="utf-8" ?>
This line called the XML prolog. This line is not necessary to write. It is the optional. If you write this line it comes in the first line of xml documents. XML documents can contain international characters. Then we get the error in our program. To avoid errors you should specify the encoding used or save your XML files as UTF-8. UTF-8 is the default character encoding for XML documents.
2.-: All element must have closing tags-: When we write any tags it is necessary to close these tags. If we write a id tag as like <id> it close </id>. It is necessary to close .
3.-: XML tags are case sensitive-: XML tags are case sensitive. It is necessary that the starting tag and closing tags are the same. If we write a starting tag <message> then the closing tag must be </message>.This is the right way. If we write closing tag </Message> then this is showing error and this is wrong.
4-:XML tags are well format-: XML tags are use in well formed. Like the HTML language First tag close in last and last one close in first. For example
<bold> <italic> <underline> <heading> ........ </heading> </underline> </italic> </bold>
5-: XML attribute value must be in double quoted -: XML elements can have attributes in name/value pairs just like in HTML. For example
<company> <employee> <full name="Topper of batch">vikram singh</full> </employee> </company>
6.-:Entity References -: Some character in the xml language have a special meaning. If we write “<” this character in the xml . It showing the error because the parser interprets it as the start of a new element. In the xml has some entity reference . these are the
- < less then
- > grater then
- & ampresend
- ‘ single quoted
- ” double quoted
7.- White space preserved in XML-: XML does not truncate multiple white-spaces
8. XML Stores New Line LF-: Windows applications store a new line using (CR+LF). XML stores a new line as LF.