呵呵,上帝不知道如何在VB中创建XML文档?注意加引用MICROSOFT XML 3。0' Create DOM Document
Dim doc As MSXML2.DOMDocument
Set doc = New MSXML2.DOMDocument ' Create Document Element
Dim root As MSXML2.IXMLDOMElement
Set root = doc.createElement("root") ' Set Document Element
Set doc.documentElement = root ' Create new element
Dim elem As MSXML2.IXMLDOMElement
Set elem = doc.createElement("item") ' Make this element child of root
root.appendChild elem ' Add some attributes to element
elem.setAttribute "id", 1
elem.setAttribute "name", "Bob" ' add some Text content to the element
Dim text As MSXML2.IXMLDOMText
Set text = doc.createTextNode("This is some text")
elem.appendChild text ' Display the XML
MsgBox doc.xml
'displays <root><item id="1" name="Bob">This is some text</item></root>
Dim doc As MSXML2.DOMDocument
Set doc = New MSXML2.DOMDocument ' Create Document Element
Dim root As MSXML2.IXMLDOMElement
Set root = doc.createElement("root") ' Set Document Element
Set doc.documentElement = root ' Create new element
Dim elem As MSXML2.IXMLDOMElement
Set elem = doc.createElement("item") ' Make this element child of root
root.appendChild elem ' Add some attributes to element
elem.setAttribute "id", 1
elem.setAttribute "name", "Bob" ' add some Text content to the element
Dim text As MSXML2.IXMLDOMText
Set text = doc.createTextNode("This is some text")
elem.appendChild text ' Display the XML
MsgBox doc.xml
'displays <root><item id="1" name="Bob">This is some text</item></root>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货