Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Nesting of tags

 
Kezia Matthews
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Sunetra.
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic