Forum Discussion
XPath and name space
Hi everyone.
I am trying to get the <n1:Identifier> element from the XML below using xpath and xmlDoc.SelectNodes("\\Identifier") without luck. It seems that the "n1:" qualifier has to be incorporated but I cannot see how. Any suggestions?
Thanks
B.
<epcis:EPCISDocument creationDate="2019-06-10T16:23:07Z" schemaVersion="1.1" xmlns:epcis="urn:epcglobal:epcis:xsd:1" xmlns:gs1ushc="http://epcis.gs1us.org/hc/ns" xmlns:sbdh="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader">
<EPCISHeader>
<n1:StandardBusinessDocumentHeader xmlns:n1="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader">
<n1:HeaderVersion>1.0</n1:HeaderVersion>
<n1:Sender>
<n1:Identifier Authority="GLN">97823048243</n1:Identifier>
...
Hi,
I recommend using setProperty Method.
Public Sub Sample()
With CreateObject("MSXML2.DOMDocument")
.async = False
If .Load("C:\Test\Test.xml") Then
.SetProperty "SelectionNamespaces", "xmlns:n1='http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader'"
Debug.Print .SelectNodes("//n1:Identifier").Item(0).XML
End If
End With
End SubBest regards,
kinuasa
- kinuasaBrass Contributor
Hi,
I recommend using setProperty Method.
Public Sub Sample()
With CreateObject("MSXML2.DOMDocument")
.async = False
If .Load("C:\Test\Test.xml") Then
.SetProperty "SelectionNamespaces", "xmlns:n1='http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader'"
Debug.Print .SelectNodes("//n1:Identifier").Item(0).XML
End If
End With
End SubBest regards,
kinuasa