' 添加一个子节点 Dim aElement As IXMLDOMElement Set aElement = xmlDoc.createElement("xxxxyyyy") '节点名称 aElement.nodeTypedValue = "ddddddddd" '节点值 xmlDoc.documentElement.childNodes.Item(0).childNodes(0).childNodes(2).childNodes(0).appendChild aElement 保存用.save 方法
使用loadXML 方法吧,参考官方帮助中的这些节选:loadXML Method Loads an XML document using the supplied string.Res Calling load or loadXML on an existing document immediately discards the content of the document. The loadXML() will work only with UTF-16 or UCS-2 encodings.This member is an extension of the Worldwide Web Consortium (W3C) Document Object Model (DOM).[Visual Basic] Visual Basic Syntax boolValue = oXMLDOMDocument.loadXML(bstrXML) Parameters bstrXML String containing the XML string to load into this XML document object. This string can contain an entire XML document or a well-formed fragment. Return Value Boolean. Returns True if the XML load succeeded. Returns False and sets the documentElement property of the DOMDocument to Null if the XML load failed.Example The following Microsoft® Visual Basic® example creates a DOMDocument object, and then uses its loadXML method to load the specified XML before displaying it.Dim xmlDoc As New Msxml2.DOMDocument xmlDoc.async = False xmlDoc.loadXML ("<customer><first_name>Joe</first_name><last_name>Smith</last_name></customer>") MsgBox xmlDoc.xml
- <Order>
<TransID>10001</TransID>
.
.
-<Item>
<ItemID>1001</ItemID>
.
.
-<condiment>
.
oDOM.save "C:\PTout\12.xml"
Dim aElement As IXMLDOMElement
Set aElement = xmlDoc.createElement("xxxxyyyy") '节点名称
aElement.nodeTypedValue = "ddddddddd" '节点值
xmlDoc.documentElement.childNodes.Item(0).childNodes(0).childNodes(2).childNodes(0).appendChild aElement
保存用.save 方法
Loads an XML document using the supplied string.Res
Calling load or loadXML on an existing document immediately discards the content of the document. The loadXML() will work only with UTF-16 or UCS-2 encodings.This member is an extension of the Worldwide Web Consortium (W3C) Document Object Model (DOM).[Visual Basic]
Visual Basic Syntax
boolValue = oXMLDOMDocument.loadXML(bstrXML)
Parameters
bstrXML
String containing the XML string to load into this XML document object. This string can contain an entire XML document or a well-formed fragment.
Return Value
Boolean. Returns True if the XML load succeeded. Returns False and sets the documentElement property of the DOMDocument to Null if the XML load failed.Example
The following Microsoft® Visual Basic® example creates a DOMDocument object, and then uses its loadXML method to load the specified XML before displaying it.Dim xmlDoc As New Msxml2.DOMDocument
xmlDoc.async = False
xmlDoc.loadXML ("<customer><first_name>Joe</first_name><last_name>Smith</last_name></customer>")
MsgBox xmlDoc.xml
oDOM.Save “您的文件路径”
估计 createProcessingInstruction 应该在 LoadXML 之后使用。