[jdom-interest] XPath and Namespaces

Carsten Karkola carsten.karkola at mailbox.tu-dresden.de
Fri Jul 26 04:44:51 PDT 2002


Thank you for your quick response, but how do I get the b nodes in the 
following document:

<?xml version="1.0" encoding="ISO-8859-1"?>
<test
  xmlns="http://www.tu-dresden.de/bau/test"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.tu-dresden.de/bau/test test.xsd">
  <a>
    <b>test1</b>
  </a>
  <a>
    <b>test2</b>
  </a>
  <a>
    <b>test3</b>
  </a>
</test>

What should I use instead of
 org.jaxen.XPath path = new JDOMXPath("//b");
 path.addNamespace("",doc.getRootElement().getNamespace().getURI());
 List results = path.selectNodes(doc);

to get all the <b> elements. How should I add the namespace, because 
without the path.addNamespace I get also no results.

Regards, Carsten



More information about the jdom-interest mailing list