About Me

Friday, 13 April 2012

XML Tree - Sibling A sibling relationship exists when two elements have the same parent. There are no brothers or sisters in XML, only siblings. Advertise on Tizag.com Finding Your Siblings To find siblings in an XML document, look for elements that are on the same level of the tree and have the same parent. Who is the sibling of snack? XML Code, lemonade.xml: $2.50 20 $1.50 10 $4.50 60 drink is the sibling of snack. If you look at the tree structure, you can clearly see that the elements drink and snack, of the lemonade.xml document, share the same parent, inventory. XML Tree:

XML Tree - Sibling

A sibling relationship exists when two elements have the same parent. There are no brothers or sisters in XML, only siblings.

Finding Your Siblings

To find siblings in an XML document, look for elements that are on the same level of the tree and have the same parent.
Who is the sibling of snack?

XML Code, lemonade.xml:

<inventory>
 <drink>
  <lemonade>
   <price>$2.50</price>
   <amount>20</amount>
  </lemonade>
  <pop>
   <price>$1.50</price>
   <amount>10</amount>
  </pop>
 </drink>
 
 <snack>
  <chips>
   <price>$4.50</price>
   <amount>60</amount>
  </chips>
 </snack>
</inventory>
drink is the sibling of snack.
If you look at the tree structure, you can clearly see that the elements drink and snack, of the lemonade.xml document, share the same parent, inventory.

XML Tree:

0 comments:

Post a Comment