Ruby:Read XML

From Progzoo
Jump to navigation Jump to 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'/>

The REXML library allows an XPath expression such as //country to be used in place of the DOM methods "getElementsByTagName"

The value returned should be 82 million.

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