C#:Introduction to DOM Tutorial

From Progzoo
Jump to: navigation, search
The file http://progzoo.net/bbc.xml is as shown:
<world>
 <region id='Europe'>
  <country id='de' name='Germany' pop='82000000'/>
  <country id='fr' name='France'  pop='60000000'/>
 </region>
 <region id='Asia'>
  <country id='cn' name='China' pop='1300000000'/>
 </region>
</world>

This this tutorial we look at the following members of the DOM interface

DocumentElement
FirstChild
NextSibling

FirstChild NextSibling

The program shown uses FirstChild and NextSibling to print the id of the first child of the second child node.

Change the program so that it prints the id of the second child of the first child.


[Font] [Default] [Show] [Resize] [History] [Profile]

GetAttribute

Print the id and the name and the pop for the element e



[Font] [Default] [Show] [Resize] [History] [Profile]

ParentNode

The method ParentNode returns an XmlNode - you can 'cast' that to an XmlElement

Print the id and the id of the parent of element e



[Font] [Default] [Show] [Resize] [History] [Profile]