Using setAttribute Method of DOM Object in VB

Using setAttribute Method of DOM Object in VB


I am unable to use “setAttribute” method in Visual Basic. Following is the piece of code.

Dim objXML As DOMDocumentDim objOrders As IXMLDOMNodeDim objOrder As IXMLDOMNodeSet objXML = CreateObject("Microsoft.XMLDOM")Set objOrders = objXML.createElement("Orders")objXML.appendChild objOrdersSet objOrder = objXML.createElement("Order")objOrders.appendChild objOrderobjOrder.setAttribute "OrderID", rsOrderHeaders("OrderID")         

Please let me know where I am going wrong. Is there any other way to set the attribute for a node?


When I initially looked at it, I thought the problem may be in the assignment from the recordset, but it suddenly hit me that your primary problem stems from the fact that you are declaring objOrders as an IXMLDOMNode. This interface doesn’t support setAttribute, although one of its children, IXMLDOMElement, does. What you should have said was:

Dim objXML As DOMDocumentDim objOrders As IXMLDOMElementDim objOrder As IXMLDOMElement

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular