RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: XML
Expertise: Beginner
Jul 10, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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 DOMDocument
Dim objOrders As IXMLDOMNode
Dim objOrder As IXMLDOMNode

Set objXML = CreateObject("Microsoft.XMLDOM")

Set objOrders = objXML.createElement("Orders")
objXML.appendChild objOrders

Set objOrder = objXML.createElement("Order")
objOrders.appendChild objOrder
objOrder.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 DOMDocument
Dim objOrders As IXMLDOMElement
Dim objOrder As IXMLDOMElement
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date