|
XML : DTD |
|
relationships. They have simple naming rules.
XML Elements are Extensible
XML documents can be extended to carry
more information.
Look at the following XML example:
<?xml version=”1.0" encoding=”ISO-8859-
1"?>
<E-mail>
<To>Rohan</To>
<From>Amit</From>
<Body>Be ready for a cruise...i will catch u
tonight</Body>
</E-mail> |
Let’s suppose that we create an application to
fetch data from the above XML document
and produce this output:
E-mail
To: Rohan
From: Amit
Be ready for a cruise...i will catch u tonight
Now, the author wants to add a new feature
(let it be a subject line). He can easily achieve
it by adding one more tag ie..<Subject>in the
xml document. So the new modified xml
document will look like this:
<?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> |
Now the new generated output will look like
this:
E-mail
To: Rohan
From: Amit |
|
Subject: Surprise....
Be ready for a cruise...i will catch u tonight
XML Elements have Relationships
Elements in a xml document are related as
parents and children.
Imagine that this xml document is a description
of e-mail:
<?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> |
Here, E-mail is the root element while To, From,
Subject and Body are the child elements of the
E-mail. Here, E-mail is the parent element of
To, From, Subject and Body. To, From, Subject
and Body are siblings (or sister elements)
because they have the same parentage. Hence
all the XML Elements have Relationships.
XML Element Naming conventions:
XML elements must follow these naming
conventions:
Names must not start with a number or
punctuation character but it can contain letters,
numbers, and other characters without spaces.
Names must not start with the letters xml (or
XML, or Xml, etc).
XML Attributes
XML elements can have attributes in the start
tag, just like HTML. Attributes are used to
provide additional information about elements.
Attributes often provide information that
is not a part of the data. In the example below,
the file type is irrelevant to the data, but |
|
Jan
2008 | Java Jazz Up | 27 |
|
|
|
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 |
|
|
|
|
|
|
|
|
|