• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Nesting of tags

 
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.
 
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.
 
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>

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!