Magazine
 
XML : DTD
 

And finally the last line defines the end of the
root element.
</E-mail>

You may feel from this example that the XML document contains an E-mail To Rohan From Amit. Don’t you agree that XML is quite selfdescriptive?

Now let’s discuss its syntax-rules which are very simple to learn. All XML elements must have a closing tag In XML all the elements must have a closing tag like this:

<To>Rohan</To>
<From>Amit</From>

XML tags are case sensitive
XML tags are case sensitive. The tag <To> is different from the tag <to>. Hence the opening and closing tags must be written with the same case:

<To>Rohan</To>
<to>Rohan</to>

XML Elements Must be Properly Nested
Improper nesting of tags makes no sense to XML. In XML all elements must be properly nested within each other like this in a logical order:

<b><i>Hi , how are you.....</i></b>

XML Documents Must Have a Root Element
All XML documents must contain a single tag pair to define a root element. All other elements must be written within this root element. All elements can have sub elements called as child elements. Sub elements must
be correctly nested within their parent element:


 

<root>
<child>
<subchild>.....</subchild>
</child>
</root>

Always Quote the XML Attribute Values

In XML the attribute value must always be quoted. XML elements can have attributes in name/value pairs just like in HTML. Just look the two XML documents below.
The error in the first document is that the date and version attributes are not quoted .

<?xml version=1.0 encoding=”ISO-8859-
1"?>
<E-mail date=12/11/2002/>

The second document is correct:

<?xml version=”1.0" encoding=”ISO-8859-
1"?>
<E-mail date=”12/11/2002"/>

With XML, White Space is preserved

With XML, the white space in a document is preserved.

So a sentence likes this: Hello How are you, will be displayed like this:

Hello How are you,

Comments in XML

The syntax for writing comments in XML is
similar to that of HTML.

<!— This is a comment —>

XML Elements

XML Elements are extensible. They have

 Jan 2008 | Java Jazz Up |26
 
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

83, 84 , 85 , 86, 87 , 88, 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 , 100 , 101 , 102 , 103, 104 , 105 ,

106, 107,

Download PDF