I am trying to access my xml using "MSXML2' dom object using vb scripting.
Set oMessageDoc = CreateObject( "MSXML2.DOMDocument" )
however I have dynamic namespace prefix for same tag in each xml file. Example provided below
Tag-> <ns1:Addr><ns1:Street>abc street </ns1:Street> </ns1:Addr>
same tag is referred in another xml as, <ns2:Addr><ns2:Street>abc street </ns2:Street> </ns2:Addr>
I am trying to access xml tag as "ns1:Addr/ns1:Street" and "ns2:Addr/ns2:Street" though both refers same tag (ns1, ns2 are same namespace URI)
is it possible to access xmltag's xpath without prefix, as like "Addr/Street"?
First of all, with "MSXML2.DOMDocument" you are getting MSXML 3.0 for which the selection language has to be explicitly set to XPath with e.g.
oMessageDoc.setProperty "SelectionLanguage", "XPath"
As for using "Addr/Street", no, with XPath 1.0 which is all Microsoft supports that always selects elements of those names in
But of course if the elements are in the same namespace then all you need is
oMessageDoc.setProperty "SelectionNamespaces", "xmlns:ns1='http://example.com/ns'"
(where you put the namespace URI of the input XML in the place of http://example.com/ns) and then in your code you can select
MVP (XML, Data Platform Development) 2005/04 - 2013/03
Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.
Would you like to participate?