[英]Vbscript - Creating an XML file and Adding Namespace
I'm trying to use vbscript to create a xml file using the following format 我正在尝试使用vbscript使用以下格式创建xml文件
<?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. 我能够添加“产品”,“产品”和“ URL”的所有元素,但是问题是我不知道如何将xmlns添加到产品元素。
Here is my code: 这是我的代码:
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Set objRoot = xmlDoc.createElement("products")
xmlDoc.appendChild objRoot
Create an attribute xmlns
for the node: 为节点创建一个属性xmlns
:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.