Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: xpath help

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 5/1/2007 3:44:00 PM
Craig Buchanan wrote:
> I'm having difficulty with an Xpath on an XML document (snippet below) that 
> contains a default namespace.
> 
> If I remove the default namespace, this Xpath produces the desired result: 
> //li[a[@href[contains(.,'aplushomecare.org')]]].  Essentially, i want a 'li' 
> element if its contains an 'a' element with a href attribute that contains 
> the desired text.

You where shown how to use e.g.
   xmlDoc.setProperty('SelectionNamespace', 
'xmlns:xhtml="http://www.w3.org/1999/xhtml"');
to bind a prefix to the namespace URI so that you can then write XPath 
expressions like
   //xhtml:li[xhtml:a[contains(@href, 'aplushomecare.org')]]

If you don't want that then use the cumbersome local-name() approach but 
you need to keep the structure e.g.
   //*[local-name() = 'li'][*[local-name() = 'a'][contains(@href, 
'aplushomecare.org')]]
so that way you are looking for elements at all levels having the local 
name 'li' which have a child element having the local name 'a' where the 
attribute 'href' contains the string value.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent