XML ' Create DOM object
Set Objdom=server. CreateObject ("Microsoft.XMLDOM")
' Get XML data
' Method 1 Gets the XML data of the XML file
Objdom.load ("C:\test.xml")
' Method 2 Gets the data of the XML data string
Objdom.loadxml ("<people><man name=" SD "/></people>")
' Create a Node object
Set newnode=objdom.createelement ("people")
' To the value of this node
Newnode.text= "Man"
' Add attributes to this node
Set newattribute=objdom.createnode ("attribute", "name", "")
newattribute.text= "John"
Newnode.setattributenode Newattribute
' Add child nodes to this node
Set newnodechild=objdom.createelement ("address")
Newnode.appendchild Newnodechild
' Save this Node object
Objdom.appendchild Newnode
Objdom.save ("C:\test.xml")
' Find a Node object
Set Objtofind=objdom.documentelement.selectsinglenode ("//people/man")
' Take out the node name of this node object, the node value, a property value, and all the XML
Nodename=objtofind.nodename
Nodevalue=objtofind.text
Objtofind. GetAttributeNode ("name"). NodeValue ' property value named Name
' Remove an Attribute node object
Set Objattrtofind=objdom.documentelement.selectsinglenode ("//people/man"). GetAttributeNode ("name")
' Take out the attribute name of this node, attribute value
Nodeattrname=objattrtofind.nodename
Nodeattrvalue=objattrtofind.nodevalue
' Delete a Node object
Set Objnode=objdom.documentelement.selectsinglenode ("//people/man") ' the node to be deleted
Set Objparentnode=objdom.documentelement.selectsinglenode ("//people") ' parent node of the node to be deleted
Objparentnode.removechild Objnode
' Take out a set of byte points for a node
Set Objnodes=objdom.documentelement.selectsinglenode ("//people/man"). ChildNodes
Traverse this collection
Method 1
For each element in Objnodes
Response.Write Element.nodename Byte Roll Call
Response.Write Element.text Byte point value
Next
Method 2
Domlength=objnodes.length
For i = 0 to Domlength-1
Response.Write Objnodes.childnodes (i)-nodename byte Roll Call
Response.Write Objnodes.childnodes (i). Text byte point value
Next
' Remove a collection of attributes from a node
Set Objnodes=objdom.documentelement.selectsinglenode ("//people/man"). GetAttributeNode ("name"). Attributes
Traverse this collection
For each element in Objnodes
Response.Write Element.nodename Property Name
Response.Write Element.nodevalue Property Value
Next