The file 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>
The XPath expression //country[@id='fr']/@pop find the
country node that has attribute id set to 'fr',
it returns the value of the
pop attribute.
The value returned should be 60 million.
1. [ Java ] Load a DOM document and apply an XPath expression
You load the XML file via the DocumentBuilderFactory, DocumentBuilder and parser. The xPath object can be used on this to evaluate the XPath expression.