Tuesday, February 4, 2014

XML Syntax(1)

Rules for the syntax of XML:
  • A XML document must contain a pair, and only a pair, of root tags
  • All XML elements must have a opening tag and a closing Tag.
  • XML tags are case sensitive.
  • An element in XML can has its child element.
  • All elements in XML must be properly nested within each other.
  • XML attribute values must be quoted.

As you know, HTML is quite forgiving when it comes to tag placement, missing tags, and attribute values. For ex:- A web browser  will correctly interpret an HTML page even if you forget to put a closing tag, like :-
<p>I am MaHi.
<li>I iive in surat.
In XML, all elements must have a closing tag:
<p>I am MaHi</p>
<li>I live in surat</li>
In HTML, tags are not case sensitive. you can use a tag like "<head>", or "<Head>", or "<HEAD>". They all are valid. But in XML, "<head>", or "<Head>", or "<HEAD>" will be three different tags because XML Tags are case sensitive. So you must write your opening and closing tags with the same case:
<HEAD>This is incorrect</head>
<head>This is correct</head>
In HTML, even the elements are improperly nested, it may still work.:
<b><i>Bold with Italic</b></i>

XML Elements Must be Properly Nested:
<b><i>Bold with Italic</i></b>

No comments:

Post a Comment