Read XML

From Progzoo
Revision as of 22:26, 10 April 2008 by Andr3w (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
The file is as shown:
 <region id='Europe'>
  <country id='de' name='Germany' pop='82000000'/>
  <country id='fr' name='France'  pop='60000000'/>
 <region id='Asia'>
  <country id='cn' name='China' pop='1300000000'/>

You load the XML file via the DocumentBuilderFactory, DocumentBuilder and parser. You then obtain a list of all country nodes. The first node represents Germany, it must be cast as an element before you can access the pop attribute.

The value returned should be 82 million.

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