Hi,<br><br>remove space in &quot;xmlns&quot; attribute in the XML document :).<br><br>Regards,<br>Grzegorz<br><br><div><span class="gmail_quote">2007/10/22, Bhave, Ameya &lt;<a href="mailto:bhaveameya@gmail.com">bhaveameya@gmail.com
</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.opentravel.org/OTA/2003/05</a>&quot; xmlns:ns2=&quot;<a href="http://www.tui-uk.co.uk/OTA_EXT/2006" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.tui-uk.co.uk/OTA_EXT/2006</a>&quot; xmlns:ns3=&quot;
<a href="http://www.openjawtech.com/2005" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.openjawtech.com/2005</a>&quot; xmlns:ns4=&quot;<a href="http://www.opentravel.org/OTA/2002/08" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">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><span class="sg"><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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
ameya@bhaves.com</a>
</span><br>_______________________________________________<br>To control your jdom-interest membership:<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com" target="_blank">
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a><br></blockquote></div><br><br clear="all"><br>-- <br>&quot;Choć tyle wiemy własnym doświadczeniem:<br>W nas jest Raj, Piekło - i do obu - szlaki.&quot;
<br>J.K.