Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - MSXML 6.0 and .net XML - default namespaces >Thread Next - Re: MSXML 6.0 and .net XML - default namespaces Re: MSXML 6.0 and .net XML - default namespacesTo: NULL Date: 3/24/2009 5:51:00 PM 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/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
