[jdom-interest] Question about selecting nodes with XPath

Michael Kay mike at saxonica.com
Tue Jan 31 13:59:35 PST 2006

If you're selecting with the root as context node, //a:displayname will
select all the a:displayname elements. If you're at the parent of the
a:displayname element, you can select it using a:displayname. In both cases,
and this is probably where you're going wrong, you need to ensure that the
prefix a is bound in the context for the XPath expression. The way you do
that depends on the API you are using - I don't remember offhand how its
done in JDOM.

Michael Kay

> -----Original Message-----
> From: jdom-interest-bounces at jdom.org 
> [mailto:jdom-interest-bounces at jdom.org] On Behalf Of Clemens Eisserer
> Sent: 31 January 2006 20:18
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] Question about selecting nodes with XPath
> Hello,
> First of all thanks a lot for jdom, its a really well designed API and
> its fun to work with it.
> I would like to use XPath for just selecting the
> "<a:displayname>"-nodes however I tried several ways to do so and I
> only get a List with size 0 so I guess my query is somehow malformed.
> I tried "displayname", "/displayname", "a:displayname",
> "/a:displayname" however none worked.
> It would be really great if somebody could give me just a short hint
> whats wrong.
> Thank you in advance, lg Clemens
> This is an exmaple XML-File I would like to query:
> <?xml version="1.0"?><a:multistatus
> xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"
> xmlns:c="xml:" 
> xmlns:a="DAV:"><a:response><a:href>
> ser2/Kalender/</a:href><a:propstat><a:status>HTTP/1.1
> 200 
> OK</a:status><a:prop><a:displayname>Kalender</a:displayname></
> ref><a:propstat><a:status>HTTP/1.1
> 200 
> OK</a:status><a:prop><a:displayname>appointment2.eml</a:displa
> 200 
> OK</a:status><a:prop><a:displayname>{36BB053F-DF6D-4BA4-8F04-8
> 81E-BEACB7A2012F}.EML</a:href><a:propstat><a:status>HTTP/1.1
> 200 
> OK</a:status><a:prop><a:displayname>{144246DB-94E9-46E8-981E-B
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@you
> rhost.com

More information about the jdom-interest mailing list