Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - xpath help [Thread Next] Re: xpath helpTo: 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/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
