[jdom-interest] Question about using Xpath whilst using jdom beta 10

Bush, Chris cbush at lehman.com
Wed Sep 1 01:35:43 PDT 2004


I am new to Jdom and have a question. I am trying use the following code to
extract out "legIds" from the attached xml. However, I seem to get the same
legId value twice, rather than the 2 distinct values I am expecting. Am I
doing something wrong ? The output I expect is 

 Leg = leg1  
 Legid = 00066786  
 Leg = leg2  
 Legid = 00066787

But I get this instead :

 Leg = leg1  
 Legid = 00066786  
 Leg = leg2  
 Legid = 00066786

Chris Bush

  private void test( org.jdom.Document doc ) throws Exception
      org.jdom.xpath.XPath path =
      org.jdom.xpath.XPath legpath =

      List elements = path.selectNodes(doc);

      for ( int i = 0; i < elements.size(); i++ )
          org.jdom.Element e = (org.jdom.Element)elements.get(i);

          System.out.println(" Leg = " + e.getAttributeValue("legId") );

          System.out.println(" Legid = " + legpath.valueOf(e));

The xml is attached :


This message is intended only for the personal and confidential use of the
designated recipient(s) named above.  If you are not the intended recipient of
this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited.  This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this information is
complete or accurate and it should not be relied upon as such.  All
information is subject to change without notice.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 103416L.xml
Type: application/octet-stream
Size: 627 bytes
Desc: not available
Url : http://servlets.com/pipermail/jdom-interest/attachments/20040901/1e9dfdd3/103416L.obj

More information about the jdom-interest mailing list