Magazine
 

XML : DTD

 

must “invent” his tags.

The tags used to mark up HTML documents and the structure of HTML documents is predefined. The author of HTML documents can only use tags that are defined in the HTML standard (like <p>, <h1>, etc.).

XML allows the user to define his own tags and document structure.

4. XML Tags are Case Sensitive

Unlike HTML, XML tags are case sensitive. In HTML the following will work:

<Message>This is incorrect</message>

In XML opening and closing tags must therefore be written with the same case:

<message>This is correct</message>

5. XML Elements Must be Properly Nested

Improper nesting of tags makes no sense to XML.

In HTML some elements can be improperly nested within each other like this:

<b><i>This text is bold and italic</b></i>

In XML all elements must be properly nested within each other like this:

<b><i>This text is bold and italic</i></b>

6. XML is a Complement to HTML, not a replacement for HTML.

It is important to understand that XML is not a replacement for HTML. In Web development it is most likely that XML will be used to describe the data, while HTML will be used to format and display the same data.
Syntax Rules for XML

The syntax rules for XML are very simple and

 

strict. These are easy to learn and use. Because of this, creating software that can read and manipulate XML is very easy. Xml enables a user to create his own tags.

Note - XML documents use a self-describing and simple syntax

Let’s develop a simple XML document:

<?xml version=”1.0" encoding=”ISO-8859-
1"?>
<E-mail>
<To>Rohan</To>
<From>Amit</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u
tonight</Body>
</E-mail>

The XML declaration:

The XML declaration should always be included in the first line of the xml document. It defines the XML version and the character encoding used in the document. In this case the document conforms to the 1.0 specification of XML and uses the ISO-8859- 1 (Latin-1/West European) character set.

<?xml version=”1.0" encoding=”ISO-8859-
1"?>

Root Element:

The next line defines the first element of the document. It is called as the root element

<E-mail>

Child Elements:

Next 4 lines describe the four child elements of the root (To, From, Subject and Body).

<To>Rohan</To>
<From>Amit</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u
tonight</Body>
Jan  2008 | Java Jazz Up |25
 
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