Microsoft. xmldom

Source: Internet
Author: User
[Transfer] http://www.abasp.net/article/124.htm
'Get the root node set dom = Createobject ("Microsoft. xmldom ") Dom. async = falsedom. load "C: \ User. XML "set book1 = rootnode. childnodes (1) book1.ownerdocument returns the document node, point to the XML file book1.previussibling, the first subnode book1.lastchild, the parent node book1.firstchild, the first subnode book1.lastchild, And the last subnode book1.childnodes subnode set 'add node set node = rootnode. childnodes. item (0) set newnode = mydocument. createelement ("publisher") set rtnnode = node. insertbefore (newnode, Node. lastchild) set textnode = mydocument. createtextnode ("people's post and telecommunications Publishing House") node. childnodes. item (1 ). appendchild (textnode) 'delete node set node = root. childnodes. item (0) set oldnode = node. removechild (node. childnodes. item (4) 'modify node set node = root. childnodes. item (0) node. nodevalue = "158" 'common DOM method createattribute (attribute name) creates an attribute node. You can then use the setattributenode method to set this attribute to the attribute createcdatasection (content) of an element to create a CDATA node. Createmessage (content) creates a comment node. The value is the createelement (name) parameter content. createentityreference (name) creates an object reference node. If the referenced object is known, the object reference node has the same subnode set createprocessinginstruction as the corresponding entity node (processing the target part of the instruction and the data part of the instruction) create a processing command node createtextnode (content) with the specified name and data to create a text node with the specified content
Node common attribute attributeschildnodes set of child nodes firstchild first child node lastchild last child node previoussibling current node predecessor node nextsibling current node successor node nodename current node name nodetype node type nodevalue Node value of parentnodes parent node
The Node Method appendchild (newchild) is added to the end of all the child nodes. Return the added node clonenode (Boolean deep) to copy the current node. The copied node does not have a parent node, return to the copied node haschildnodes without parameters. Check whether the child node createelement creates an element node insertbefore (newchild, refchild) and inserts the node newchild before the child node refchild of the current node. Return the inserted node removechild (oldchild) to delete the child node oldchild and return the oldchild node. ReplaceChild (newchild, oldchild) replaces the node and returns that the deleted node nodelist is dynamic. Changes to the document are directly reflected in the relevant nodelist object.
Attribute: lengthitem (0)-Item (nodelist. Length-1) namednodemap contains nodes unordered. Indicates the correspondence between a node and a unique name. Property length method: getnameditem (name) returns the node item with the given name (0 ...) removenameditem (name) deletes the node setnameditem (name) with the given name and adds the node with the given node name to the current node set. If the changed name already exists, ASP has many advantages over access in retrieving and updating small data volumes by using xmldom to operate XML files on the server. I have tested whether to use a database and store all the Website member information, product data information, transaction information, and website customization information in three XML files. The running result is normal, it seems that it is much faster than the database, but it is not tested and cannot be determined.
The following describes how to create, query, and modify a DOM object set objdom = server. createobject ("Microsoft. xmldom ") 'Get XML data' method 1 get XML data of the XML file objdom. load ("C: \ test. XML ") 'method 2: Get the data objdom of the XML data string. loadxml ("<people> <man name =" SD "/> </People>") 'creates a Node object set newnode = objdom. createelement ("people") 'returns newnode to this node. TEXT = "person" 'adds the attribute set newattridom = objdom to this node. createnode ("attribute", "name", "") newattride. TEXT = "James" newnode. setattributenode newattribute 'adds a subnode set newnodechild = objdom to this node. createelement ("Address") newnode. appendchild newnodechild 'Save this Node object objdom. appendchild newnodeobjdom. save ("C: \ test. XML ") 'query a Node object set objtofind=objdom.doc umentelement. selectsinglenode ("// people/Man") 'retrieves the node name, node value, attribute value, and all xmlnodename = objtofind. nodenamenodevalue = objtofind. textobjtofind. getattributenode ("name "). nodevalue' attribute name attribute value 'retrieves an attribute Node object set objattrtofind1_objdom.doc umentelement. selectsinglenode ("// people/Man "). getattributenode ("name") 'retrieves the attribute name of the node. The attribute value nodeattrname = objattrtofind. nodenamenodeattrvalue = objattrtofind. nodevalue' deletes a Node object set objnode1_objdom.doc umentelement. selectsinglenode ("// people/Man") 'the node set objparentnode1_objdom.doc umentelement to be deleted. selectsinglenode ("// people") 'parent node of the node to be deleted objparentnode. removechild objnode' retrieves the byte Point Set objnodes1_objdom.doc umentelement of a node. selectsinglenode ("// people/Man "). childnodes 'traverse this set' method 1 for each element in objnodesresponse. write element. nodename byte name response. write element. text byte value next 'method 2 domlength = objnodes. lengthfor I = 0 to domlength-1response.write objnodes. childnodes (I ). nodename byte name response. write objnodes. childnodes (I ). the text byte value "Next" is used to retrieve the attribute set objnodes1_objdom.doc umentelement of a node. selectsinglenode ("// people/Man "). getattributenode ("name "). attributes 'traverses this set for each element in objnodesresponse. write element. nodename property name response. write element. nodevalue attribute value next

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.