Reputation: 149
I'm trying to use vbscript to create a xml file using the following format
<?xml version="1.0" encoding="UTF-8"?>
<products xmlns="http://www.myurl.com">
<product>
<url>http://www.link.com</url>
</product>
I was able to add all the elements for "products", "product" and "url", but the problem is that I don't know how to add the xmlns to the products element.
Here is my code:
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Set objRoot = xmlDoc.createElement("products")
xmlDoc.appendChild objRoot
Upvotes: 1
Views: 7140
Reputation: 200293
Create an attribute xmlns
for the node:
Set xmlDoc = CreateObject("Msxml2.DOMDocument.6.0")
Set objRoot = xmlDoc.createElement("products")
Set xmlns = xmlDoc.createAttribute("xmlns")
xmlns.text = "http://www.myurl.com"
objRoot.setAttributeNode xmlns
xmlDoc.appendChild objRoot
Upvotes: 1