[jdom-interest] Xpath element returning NULL

Laurent Bihanic laurent.bihanic at atosorigin.com
Wed Jun 22 01:40:37 PDT 2005


Anand, Rajesh wrote:
> I'm trying to locate this element, code snippet…
> 
> * Element element1 = (Element) XPath.selectSingleNode(pf.doc, 
> "SOAP-ENV:Envelope/SOAP-ENV:Body/getIndex:IndexServiceRequest/getIndex:EndDate");*

You need to register the namespaces to the XPath :

XPath xpath = new 
XPath("SOAP-ENV:Envelope/SOAP-ENV:Body/getIndex:IndexServiceRequest/getIndex:EndDate");
xpath.addNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
xpath.addNamespace("getIndex", 
"http://namespace.worldnet.com/EDSI/Product/Services/GetIndexData_v1_0/"

Element element1 = (Element) xpath.selectSingleNode(pf.doc);

Laurent

-- 
                  wWw
                 (o o)
-------------ooO-(_)-Ooo-----------------------------------------------
Laurent Bihanic                | Tel: +33 (0)1 55.91.21.93 (direct)
AtosOrigin Systems Integration |      +33 (0)1 55.91.20.00
Generic Solutions / SC         | Fax: +33 (0)1 55.91.22.31
Les Miroirs - Bat. C           |
18, avenue d'Alsace            |
F-92926 La Defense Cedex       | E-mail: laurent.bihanic at atosorigin.com
-----------------------------------------------------------------------

Very funny, Scotty. Now beam down my clothes.


DISCLAIMER:
The opinions expressed are entirely my own and may not necessarily be
those of my employer.  Also, I am not now nor have I ever been a
lawyer.  My opinions are provided as-is with absolutely no warrantee of
merchantability or fitness for any particular use.  Besides, you can't
prove I typed this.  No body saw me type this.  Who says I typed this?


More information about the jdom-interest mailing list