What is the easiest way in Dom4J to specify an XPath expression for a
document where you know the namespace URI of the desired nodes, but
not the prefix? Ie in:
<?xml version='1.0'?>
<my:aaa xmlns:my="http://www.example.org/my/"
xmlns:his="http://www.example.org/his/">
<my:bbb>
<my:xxx/>
<his:xxx/>
</my:bbb>
</my:aaa>
I want to select element my:xxx, but I don't know the prefix "my",
only "http://www.example.org/my/". I can navigate to it using QNames,
but I want to use a single XPath expression. I can do it by hand:
Namespace ns = root.getNamespaceForURI("http://www.example.org/my/");
String prefix = ns.getPrefix();
doc.selectNodes("/" + prefix ":aaa/" + prefix + ":bbb/" + prefix + ":xxx");
but that gets ugly. Is there a way I can do something like:
doc.selectNodes("/aaa/bbb/xxx", ns);
or
doc.selectNodes(new XPathExpression("/aaa/bbb/xxx", ns));
or some such?
-- Martijn
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user