Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: How to use XPATH on SVG?

From: Martin Honnen <mahotrash@-----.-->
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/


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