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:46:00 PM * Craig Buchanan wrote in microsoft.public.xml: >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. > >I tried >//*[local-name()='li'][local-name()='a'][@href[contains(.,'aplushomecare.org')]], >but it returns no nodes. > >Any assistance would be appreciated. You need to setup a prefix for the default namespace and use that prefix in the expression. How to do that depends on what XML toolkit you use. The expression you are looking for is e.g. //xhtml:li[ xhtml:a[ contains(@href, 'aplus...') ] ] Matching only on the local-name() (and ideally also the namespace-uri()) would also work, but the latter expression above matches any element with a local-name() that is both 'li' and 'a', which is impossible. -- Björn Höhrmann · mailto:bjoern@h... · http://bjoern.hoehrmann.de Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
