Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: 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/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/ > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
