Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 and XML namespace declarations

Status
Not open for further replies.

gezzer

Programmer
Apr 14, 2005
1
GB
I have a VB6 function which loads and examines XML. The XML contains a collection of sets of data about 'Orders'. The function loads this, breaks it down into individual orders and then sends each one to a Message Queue.

e.g.


Dim xmlDocOrders As MSXML2.DOMDocument40
Dim xmlNdlOrders As MSXML2.IXMLDOMNodeList
Dim xmlNodOrder As MSXML2.IXMLDOMNode

' Some code...

Set xmlDocOrders = New MSXML2.DOMDocument40
xmlDocOrders.Load "File Path"
Set xmlNdlOrders = xmlDocOrders.selectNodes("/ROOT/Order")
For Each xmlNodOrder In xmlNdlOrders
' Iterate through the orders, sending each one to the message queue...
Next


This has worked fine, until recently when I have been asked to add a new namespace declarations to my XML.
The XML now looks a little like this: (but with some info)


<ROOT>
<ns0:Order xmlns:sn0=" ' Some more nodes (but no other attempted namespace declarations.)
</ns0:Order>
</ROOT>


The XML appears to be fine, as it loads into IE with no parser errors.
When I run the function, it loads the XML document okay, but then I get an error when it tries to populate the node list.
I have altered the line to read:

Set xmlNdlOrders = xmlDocOrders.selectNodes ("/ROOT/ns0:Order")


The error I get is:
"Reference to undeclared namespace prefix: 'ns0'."

It makes no sense to me, as I think I have declared it perfectly well. Has anybody else experienced this sort of behaviour? Can anybody explain why I am getting this error? Thanks, gezzer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top