Hi,
My problem exists when the attribute is prefixed with a namespace.
For example, consider the following node saved in a file called test.xml.
<test xmlns="http://www.testsite.ca" xmlns:abc="http://www.abc.ca/test" identifier="XYZ"></test>
Now consider the following code (using
VB 6.0 and MSXML 4.0)
Code:
'*********START**************
Set XmlLoadDocument = New MSXML2.DOMDocument40
'Set namespace properties
Call XmlLoadDocument.SetProperty("SelectionNamespaces", "xmlns:testNS='http://www.testsite.ca'" )
'Load test.xml into a XML document called test
Call XmlLoadDocument.Load(test.xml)
'Use XPath to retrieve the node
Set tempNode = XmlLoadDocument.selectSingleNode("testNS:test[@testNS:abc = 'http://www.abc.ca/test']")
'*************END*************
The node tempNode is null (Nothing). No nodes are returned.
I have also tried executing,
Code:
Set tempNode = XmlLoadDocument.selectSingleNode("testNS:test[@abc = 'http://www.abc.ca/test']")
and
Code:
Set tempNode = XmlLoadDocument.selectSingleNode("testNS:test[@* = 'http://www.abc.ca/test']")
none of which return any nodes.
However, if I execute
Code:
Set tempNode = XmlLoadDocument.selectSingleNode("testNS:test[@identifier = 'XYZ']")
then I get the proper results. A node is returned.
This leads me to believe that the problem exists when attributes are prefixed with a namespace.
Anyone know how to get past this problem????