Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: MSXML 6.0 and .net XML - default namespaces

From: snorberg@----------.------
To: NULL
Date: 3/25/2009 10:13:00 AM
Martin,

This is a little different twist on things using a namespaced reference even 
though the original document does not use a namespace.

I will have to give that a try. In .net you would create a namespacemanager 
with the default url and then reference the nodes without the namespace 
syntax, selectSingleNode( "root/bar" )

Thanks for the response. I also need to dig in a little deeper into the 
xpath 1.0 statements. I found those in several articles that I now need to 
research a bit more. 
-- 
Scott Norberg


"Martin Honnen" wrote:

> Scott Norberg wrote:
> > I have read that MSXML 4-6 only support XPath 1.0 which does not support 
> > default namespaces.
> 
> MSXML 3-6 support XPath and XSLT 1.0, that is correct. However the 
> Microsoft .NET framework APIs like XPathNavigator and 
> XslCompiledTransform do not support XPath and XSLT 2.0 either.
> So unless you use third party tools like Saxon or AltovaXML tools you 
> have the same XSLT and XPath support with MSXML and .NET.
> 
> As for "XPath 1.0" "does not support default namespaces", I am not sure 
> what you want to say with that. You can parse XML documents using 
> default namespace declarations with both MSXML and .NET and then use 
> XPath 1.0 to select nodes in those namespace by binding a prefix to a 
> namespace and by using that prefix in your XPath expression.
> 
> With MSXML you would use setProperty('SelectionNamespaces', 
> 'xmlns:prefix="http://example.com/foo"'), with .NET you would use an 
> XmlNamespaceManager and pass that to Select/SelectSingleNode calls (with 
> XPathNavigator) or SelectNodes/SelectSingleNode calls (with 
> XmlDocument/XmlNode).
> 
> 
> Here is an example with JScript and selectSingleNode and MSXML 6:
> 
> var doc = new ActiveXObject('Msxml2.DOMDocument.6.0');
> doc.loadXML('<root 
> xmlns="http://example.com/foo"><bar>foobar</bar></root>');
> doc.setProperty('SelectionNamespaces', 'xmlns:df="' + 
> doc.documentElement.namespaceURI + '"');
> var bar = doc.selectSingleNode('df:root/df:bar');
> alert(bar.text)
> 
> Works fine.
> 
> 
> 
> -- 
> 
> 	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