Let's talk about the main method of creating, querying, modifying the operation of XML operations
'Create a DOM object
set objdom = server.createObject (microsoft.xmldom)
'Get XML data
'Method 1 Get the XML data of the XML file
objdom.load (C: /Test.xml)
'Method 2 Get the data of the XML data string
objdom.loadxml (
'Create a node object
Set newNode = objdom.createelement (people)
'To value this node
Newnode.text = people
'Add attributes to this node
Set newAttribute = Obj bellow.createNode (Attribute, name,)
Newattribute.text = Zhang San
NewNode.setAttributeNode NewAttribute
'Add sub -nodes to this node
Set newNodeChild = Objnds.createElement (address)
NewNode.appendingChild NewNodechild
'Save this node object
objdom.appendingchild newNode
objdom.save (C: /Test.xml)
'Find a node object
set obJTOFIND = objdom.documentelement.selectsingLende (// people/man)
'Take out the node name, node value, a certain attribute value, and all the XML
nodename = objtofind.nodename
nodevalue = objtofind.text
objtofind.getattributeNode (name). Nodevalue 'attribute name name name value
'Take out a attribute node object
set objattrtofind = object.documenetElement.SelectsingLenode (// people/man). GetattributeNode (name)
'Remove the attribute name, attribute value of this node
nodeattrname = objattrtoFind.NodeName
nodeAttRVALUE = ObjattrtoFind.NodeValue
'Delete an object of a node
set objnode = object.documentedLement.selectsingLende (// people/man) ''
set objpaRentnode = Objnds.documentedLement.SelectsingLeNode (// People) 'The parent node of the node to be deleted
Webjx.com
objparentnode.removechild objnode
'Take out the byte node collection of a node
set objnodes = objdom.documentelement.selectsingLende (// people/man) .ChildNodes
Traversing this collection
Method 1
for Element in Objnodes
response.write element.nodename byte node name
response.write element.text byte value
next
Method 2
domlength = objnodes.length
for i = 0 to domell-1
response.write objnodes.childNodes (i). NodeName byte node name
response.write objnodes.childNodes (i) .text byte node value
next
'Take out the attribute collection of a node
set objnodes = objdom.documentelement.selectsingLende (// people/man) .getattributeNode (name) .attributes
Traversing this collection
for Element in Objnodes
response.write element.nodename attribute name
response.write element.nodevalue attribute value
next
When you can use the XMLDOM object to operate the XML file, you can enjoy it
Many functions under ASP are implemented by XMLHTTP objects.