Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - How to use XPATH on SVG? [Thread Next] Re: How to use XPATH on SVG?To: NULL Date: 11/5/2008 2:22:00 PM Siegfried Heintze wrote: > Below is a simplified version of the file from which I am trying to use > XPATH to extract some values. My code seems to work with no namespaces but > the SVG namespaces are messing me up (I think). > > Here is my XPATH I'm trying to parse with MSXML2. I've tried it with and > without the "svg:" and it does not work. > //L"/html/body/form/table/tbody/tr[2]/td/svg:svg/svg:g/svg:text/[@class=\"tch\"]" > > L"/html/svg:svg/svg:g/svg:text/[@class=\"tch\"]" That is not correct XPath syntax, you can't do /[...] so drop the slash e.g. L"/html/svg:svg/svg:g/svg:text[@class=\"tch\"]" Also with MSXML (3 and later) to use XPath expressions with prefixes you need to call setProperty("SelectionNamespaces", "namespace bindings") e.g. (pseudo code in JScript syntax) xmlDoc.setProperty("SelectionNamespaces", "xmlns:xhtml='http://www.w3.org/1999/xhtml' xmlns:svg='http://www.w3.org/2000/svg'"); then you can use the prefixes in your XPath expressions e.g. /xhtml:html/xhtml:body/xhtml:form/xhtml:table/xhtml:tbody/xhtml:tr[2]/xhtml:td/svg:svg/svg:g/svg:text[@class="tch"] Also note that with MSXML 3 you first need to select XPath as the selection language e.g xmlDoc.setProperty("SelectionLanguage", "XPath"); -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
