aspose file tools*
The moose likes XML and Related Technologies and the fly likes Nesting of tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Nesting of tags" Watch "Nesting of tags" New topic
Author

Nesting of tags

Kezia Matthews
Ranch Hand

Joined: May 19, 2001
Posts: 107
Hi,
An example that I came across for the nesting of tags is
<root>
<element1>
<subelement1>
content1
</subelement1>
<subelement2>
content2
</subelement2>
</element1>
<element2>
<subelement1>
content1
</subelement1>
<subelement2>
content2
</subelement2>
</element2>
</root>
Can I have a nesting like this?
<root>
<element1>
<element2>
<subelement1>
content1
</subelement1>
<subelement2>
content2
</subelement2>
<element2>
</element1>
</root>
Kezia.
Sunetra Saha
Ranch Hand

Joined: Feb 25, 2001
Posts: 77
This looks perfectly okay. as long as the nesting does not overlap -it is no problem. For example :
<root>
<node1>
<branch1>
<leaf1>
</branch1>
</leaf1>... will not work.
Kezia Matthews
Ranch Hand

Joined: May 19, 2001
Posts: 107

Thanks Sunetra.
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
You have forgotten to cloase the <element2> tag.
XML allows for hierarchically structured data, which means that an element can contain other elements.
You can even have an empty tag. e.g. <tagname/>
<slide>
<title>Overview</title>
<item>Why
<em>WonderWidgets</em>
are great
</item>
<item/>
<item>Who <em>buys</em> WonderWidgets</item>
</slide>


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nesting of tags