Appending a IXMLDOMElement to a IXMLDOMNode
Posted on 2002-03-21
In my HTML page, I have a data island containing a list of customers which are diplayed on screen. When the user clicks on a button, I use a MSXML2.XMLHTTP.3.0 object in a VBScript to connect to an ASP page, which connects to our SQL database, calls a stored procedure and returns all known addresses for the currently selected employee. All this works fine.
I would like to add the addresses to the data island so that I don't need to make another round trip if the user selects the same customer during his session but when I call the appendChild method, I get the following error message: "The parameter is incorrect".
Here is my VBScript code:
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
objXMLHTTP.open "POST", "xt_GetDomainData.asp?CustomerId=" & nCustomerId & "&Data=Addresses", False
Set objAddresses = objXMLHTTP.responseXML.documentElement.selectSingleNode("//Addresses")
' xmlData is the data island
Set objCustomerNode = xmlData.XMLDocument.selectSingleNode("/Customers/Customer[CustomerId='" & nCustomerId & "']")
' This is for debugging purposes
MsgBox "From XMLHTTP: " & TypeName(objAddresses) & vbCrLf & "From Data Island: " & TypeName(objCustomerNode)
' This line fails
If I display the type name of objAddresses I see that it's a IXMLDOMElement while objCustomerNode is a IXMLDOMNode and I'm guessing that the fact the two are not the same type is causing this problem.
My question is: is there a way to "cast" objAddresses into an object type that can be appended to the data island?