Java Mailing List Archive

Home » Home (12/2007) » JDOM User »

RE: [jdom-interest] XPATH using JDOM returns null???

Anand, Rajesh


     You are absolutely right about the missing end tag. It was an error of copy & paste.
    However, what can I do with namespace as this is sent from another system.
    Any Ideas???

Rajesh Anand

-----Original Message-----
From: Kevin L. Cobb []
Sent: 15 July 2005 16:59
To: Anand, Rajesh
Subject: RE: [jdom-interest] XPATH using JDOM returns null???

Assuming your XML snippet has a cut-and-paste error, missing 'Batch' and 'FIXML' end tags, I ran it in my app and the nodeList does not come back NULL. It does, however, come back empty. If you take out the namespace declaration in the root node, FIXML, it works as expected.
I'm pretty sure the problem is that this changes the namespace of the element, FIXML, and this is why the XPATH does not see it. I can't tell you what to do to fix it though.

From: [] On Behalf Of Anand, Rajesh
Sent: Friday, July 15, 2005 10:57 AM
Subject: [jdom-interest] XPATH using JDOM returns null???


        I'm parsing an XML file using the following snippet..

        XPath xpath = XPath.newInstance("/FIXML/Batch/TrdCaptRpt");
                List nodelist = xpath.selectNodes(doc);
                Iterator nd = nodelist.iterator();
                while (nd.hasNext()){
                Element ndele = (Element);

        This is the xml snip…

        - <FIXML r="20030618" s="20040109" v="4.4" xr="FIA" xv="1" xmlns="">
- <Batch>
- <TrdCaptRpt RptID="29770863" PrevlyRpted="N" LastQty="1" LastPx="156.4" TrdDt="2005-07-13" TransTyp="0" RptTyp="2" TrdTyp="0" MtchID="0043025" BizDt="2005-07-13" MtchStat="0">

<Instrmt Sym="VX" ID="VX" Src="8" CFI="FFICSX" MMY="200602" MatDt="2006-02-15" Mult="100" Exch="XCBF" />
- <RptSide Side="1" InptDev="MR" Ccy="USD" PosEfct="O">
<Pty ID="OCC" R="21" />
- <Pty ID="00299" R="1">
<Sub ID="C" Typ="26" />
<Pty ID="PJZ" R="2" />
- <RptSide Side="2" InptDev="MR" Ccy="USD" PosEfct="C">
<Pty ID="OCC" R="21" />
- <Pty ID="00643" R="18">
<Sub ID="C" Typ="26" />
<Pty ID="TM1" R="26" />

        Why does nodelist returns NULL???

        Thanks for your help in advance.


Rajesh Anand

If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail.

To control your jdom-interest membership:
©2008 - Jax Systems, LLC, U.S.A.