Detailed description of xmldom object Methods page 1/2

Source: Internet
Author: User

Abort Method
For use
The abort method cancels an asynchronous download in progress.
Basic syntax
Xmldocument. Abort ();

Description
If this method is called during asynchronous download, all resolution actions will stop and files in the memory will be released.

Example
Xmldocument
Bytes -------------------------------------------------------------------------------------
Appendchild Method
For use
Add a node as the final sub-node of the specified node.
Basic syntax
Xmldocumentnode. appendchild (newchild );

Description
Newchild is the address for attaching a subnode.

Example
Docobj = xmldoc.doc umentelement;
Alert (docobj. XML );
Objnewnode = docobj.appendchild(xmldoc.doc umentelement. firstchild );
Alert (docobj. XML );
Bytes -------------------------------------------------------------------------------------
Clonenode Method
For use

Basic syntax
Xmldocumentnode. clonenode (deep );

Description
Deep is a Boolean value. If this parameter is set to true, the node copies all nodes developed from the specified node. If it is false, only the specified node and its attributes are copied.

Example
Currnode = xmldoc.doc umentelement. childnodes. Item (1 );
Objclonednode = currnode. clonenode (1 );
Alert (objclonednode. XML );
Bytes -------------------------------------------------------------------------------------
Createattribute Method
For use
Creates an attribute with a specified name.
Basic syntax
Xmldocument. createattribute (name );

Description
Name is the name of the created property.

Example
Objnewatt = xmldoc. createattribute ("encryption ");
Alert (objnewatt. XML );
Bytes -------------------------------------------------------------------------------------
Createcdatasection Method
For use

Basic syntax
Xmldocument. createcdatasection (data );

Description
Date is a string that contains information that is stored in CDATA.

Example
Objnewcdata = xmldoc. createcdatasection ("this is a CDATA section ");
Alert (objnewcdata. XML );
Bytes -------------------------------------------------------------------------------------
Createcomment Method
For use

Basic syntax
Xmldocument. createcomment (data );

Description
Data is a string that contains information that is placed on the annotation.

Example
Objnewcomment = xmldoc. createcomment ("this is a comment ");
Alert (objnewcomment. XML );
Bytes -------------------------------------------------------------------------------------
Createdocumentfragment Method
For use
Creates an empty File Fragment object.
Basic syntax
Xmldocument. createdocumentfragment ();

Description
A new file segment is created but not added to the file tree. To add fragments to the file tree, you must use the insert method, such as insertbefore, replaceChild, or appendchild.

Example
Objnewfragment = xmldoc. createdocumentfragment ();
Alert (objnewfragment. XML );
Bytes -------------------------------------------------------------------------------------
Createelement Method
For use
Creates an element with a specified name.
Basic syntax
Xmldocument. createelement (tagname );

Description
Tagname is a case-sensitive string to specify the name of a new element.

Example
Objnewelement = xmldoc. createelement ("");
Alert (objnewelement. XML );
Bytes -------------------------------------------------------------------------------------
Createentityreference Method
For use
Create an object with the specified name.
Basic syntax
Xmldocument. createentityreference (name );

Description
Name is a case-sensitive string used to specify the name of a new object reference. A new object reference is created but not added to the file tree. To add object references to the file tree, you must use an insert method, such as insertbefore, replaceChild, or appendchild.
Example
Objnewer = xmldoc. createentityreference ("EREF ");
Alert (objnewer. XML );
Bytes -------------------------------------------------------------------------------------

Load Method
For use
Indicates the file to be loaded from the specified position.
Basic syntax
Boolvalue = xmldocument. Load (URL );

Description
The URL contains the string of the URL of the file to be loaded. If the file is successfully loaded, the return value is true. If loading fails, the returned value is false.

Example
Boolvalue = xmldoc. Load ("lsta_1.xml ");
Alert (boolvalue );
Bytes -------------------------------------------------------------------------------------
Loadxml Method
For use
Load an XML file or a string segment.
Basic syntax
Boolvalue = xmldocument. loadxml (xmlstring );

Description
Xmlstring is a string that contains an XML text code.

Example
Xmlstring = "<greeting> <message> hello! </Message> </greeting> ";
Boolvalue = xmldoc. loadxml (xmlstring );
Alert (boolvalue );
Bytes -------------------------------------------------------------------------------------
Nodefromid Method
For use
Return the node whose ID matches the specified value.
Basic syntax
Xmldocumentnode = xmldocument. nodefromid (idstring );

Description
Idstring is a string containing the id value. The node must be of the ID type. If yes, an object is returned. If the operation fails, null is returned.

Example
Objdocumentnode = xmldoc. nodefromid ("");
Alert (objdocumentnode );
Bytes -------------------------------------------------------------------------------------
Parsed Method
For use
It verifies that the specified node and its derived sub-nodes (descendants) have been parsed.
Basic syntax
Boolvalue = xmldocumentnode. parsed ();

Description
If all nodes have been parsed, the return value is true. If any node has not been parsed, the return value is false.

Example
Currnode = xmldoc.doc umentelement. childnodes. Item (0 );
Boolvalue = currnode. parsed ();
Alert (boolvalue );
Bytes -------------------------------------------------------------------------------------
Removechild Method
For use
The specified node is removed from the node list.
Basic syntax
Objdocumentnode = xmldocumentnode. removechild (oldchild );

Description
Oldchild is a Node object that contains the node to be removed.

Example
Objremovenode = xmldoc.doc umentelement. childnodes. Item (3 );
Alert (xmldoc. XML );
Xmldoc.doc umentelement. removechild (objremovenode );
Alert (xmldoc. XML );
Bytes -------------------------------------------------------------------------------------
ReplaceChild Method
For use
Replace the specified old subnode as the new subnode.
Basic syntax
Objdocumentnode = xmldocumentnode. replaceChild (newchild, oldchild );

Description
Newchild is the object that contains the new subnode. If this parameter is null, the old subnode is removed and not replaced. Oldchild is the object that contains the old child node.

Example
Objoldnode = xmldoc.doc umentelement. childnodes. Item (3 );
Objnewnode = xmldoc. createcomment ("I 've replaced the BCC element .");
Alert (xmldoc. XML );
Xmldoc.doc umentelement. replaceChild (objnewnode, objoldnode );
Alert (xmldoc. XML );
Bytes -------------------------------------------------------------------------------------

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.