Hi,<br><br>I have read some of the literature on this subject in the archives, and am still unable to sort my problem out. Basically I am trying to read an xml file using an xpath expression.<br><br>My xml file looks like this:
<br><br>------<br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;OTA_AirLowFareSearchRQ EchoToken=&quot;0&quot; MaxResponses=&quot;20&quot; Mode=&quot;MasterPricer&quot; SequenceNmbr=&quot;0&quot; Target=&quot;Amadeus&quot; xmlns=&quot;
<a href="http://www.opentravel.org/OTA/2003/05">http://www.opentravel.org/OTA/2003/05</a>&quot; xmlns:helper=&quot;xalan://com.openjaw.rules.XSLHelper&quot; xmlns:xalan=&quot;<a href="http://xml.apache.org/xalan">http://xml.apache.org/xalan
</a>&quot;&gt;<br>&nbsp;&nbsp;&nbsp; &lt;POS&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;Source ISOCurrency=&quot;GBP&quot; PseudoCityCode=&quot;1AC&quot;&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;ns1:RequestorID ID=&quot;H6265/AAA/32835/2006/41000/OPENJAW/MERLIN&quot; ID_Context=&quot;ABTA&quot; xmlns:ns1=&quot;
<a href="http://www.opentravel.org/OTA/2003/05">http://www.opentravel.org/OTA/2003/05</a>&quot; xmlns:ns2=&quot;<a href="http://www.tui-uk.co.uk/OTA_EXT/2006">http://www.tui-uk.co.uk/OTA_EXT/2006</a>&quot; xmlns:ns3=&quot;
<a href="http://www.openjawtech.com/2005">http://www.openjawtech.com/2005</a>&quot; xmlns:ns4=&quot;<a href="http://www.opentravel.org/OTA/2002/08">http://www.opentravel.org/OTA/2002/08</a>&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/Source&gt;
<br>&nbsp;&nbsp;&nbsp; &lt;/POS&gt;<br>&nbsp;&nbsp;&nbsp; &lt;OriginDestinationInformation&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;DepartureDateTime&gt;2007-10-23T00:00:00.000+01:00&lt;/DepartureDateTime&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;OriginLocation CodeContext=&quot;IATA&quot; LocationCode=&quot;LGW&quot;/&gt;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;DestinationLocation CodeContext=&quot;IATA&quot; LocationCode=&quot;PMI&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/OriginDestinationInformation&gt;<br>&nbsp;&nbsp;&nbsp; &lt;OriginDestinationInformation&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;DepartureDateTime&gt;2007-10-30T00:00:00&lt;/DepartureDateTime&gt;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;OriginLocation CodeContext=&quot;IATA&quot; LocationCode=&quot;PMI&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;DestinationLocation CodeContext=&quot;IATA&quot; LocationCode=&quot;LGW&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/OriginDestinationInformation&gt;
<br>&nbsp;&nbsp;&nbsp; &lt;TravelerInfoSummary&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;AirTravelerAvail&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;PassengerTypeQuantity Code=&quot;ADT&quot; Quantity=&quot;2&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;PassengerTypeQuantity Code=&quot;CHD&quot; Quantity=&quot;3&quot;/&gt;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/AirTravelerAvail&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/TravelerInfoSummary&gt;<br>&lt;/OTA_AirLowFareSearchRQ&gt;<br><br>------<br clear="all"><br>And the code to access the info (using xpath) is:<br><br>-------<br>public static void getXPathValue(File file)
<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Document xmlDoc = getDocumentForFile(file);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XPath.setXPathClass(org.jaxen.jdom.JDOMXPath.class);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XPath xPath = XPath.newInstance(&quot;/ota:OTA_AirLowFareSearchRQ/ota:OriginDestinationInformation&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xPath.addNamespace(&quot;ota&quot;, &quot;<a href="http://www.opentravel.org/OTA/2003/05">http://www.opentravel.org/OTA/2003/05</a>&quot;); //default ns<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xPath.addNamespace(&quot;helper&quot;, &quot;xalan://com.openjaw.rules.XSLHelper&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xPath.addNamespace(&quot;xalan&quot;, &quot;<a href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xPath.addNamespace(&quot;ns2&quot;, &quot;<a href="http://www.tui-uk.co.uk/OTA_EXT/2006">
http://www.tui-uk.co.uk/OTA_EXT/2006</a>&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xPath.addNamespace(&quot;ns1&quot;, &quot;<a href="http://www.openjawtech.com/2005">http://www.openjawtech.com/2005</a>&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xPath.addNamespace(&quot;ns3&quot;, &quot;
<a href="http://www.opentravel.org/OTA/2002/08">http://www.opentravel.org/OTA/2002/08</a>&quot;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br><br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List nodes = xPath.selectNodes(xmlDoc);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&quot;Nodes = &quot; + nodes);
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception e)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&quot;Error: &quot; + e);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace(System.out);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}<br>-------<br><br>The problem is that the list I get is empty.
<br><br>-- <br>____________________________<br>Yours ever,<br>Ameya Bhave<br>(M) +44 07894080785<br>(H)&nbsp;&nbsp;+44 02476410217<br>(E)&nbsp;&nbsp;<a href="mailto:ameya@bhaves.com">ameya@bhaves.com</a>