Xmldom Object Method: Document Object method

Source: Internet
Author: User
Tags add object cdata contains insert string tagname xsl
dom|xml| objects

Abort method

Role

Abort method cancels an asynchronous download in progress

Basic syntax

Xmldocument.abort ();

Description

If this method is called when downloading asynchronously, all parsing actions are stopped, and the files in memory are freed.

Example

XmlDocument

AppendChild method

Role

Plus a node as the last child node of the specified node.

Basic syntax

Xmldocumentnode.appendchild (newchild);

Description

Newchild is the address of an additional child node.

Example

Docobj = xmldoc.documentelement;
alert (docobj.xml);
Objnewnode = Docobj.appendchild (xmldoc.documentelement. firstchild);
alert (docobj.xml);

CloneNode method

Role

Basic syntax

Xmldocumentnode.clonenode (deep);

Description

Deep is a Boolean value. If true, this node replicates all nodes that are developed with the specified node. If False, only the specified node and its properties are replicated.

Example

Currnode = XmlDoc.documentElement.childNodes.item (1);
Objclonednode = Currnode.clonenode (1);
alert (objclonednode.xml);

CreateAttribute method

Role

Creates a property of the specified name.

Basic syntax

Xmldocument.createattribute (name);

Description

Name is the names of the properties being built.

Example

Objnewatt = Xmldoc.createattribute ("Encryption");
alert (objnewatt.xml);

Createcdatasection method

Role

Basic syntax

Xmldocument.createcdatasection (data);

Description

Date is a string that contains data that is placed in CDATA.

Example

Objnewcdata = Xmldoc.createcdatasection ("This are a CDATA section");
alert (objnewcdata.xml);

Createcomment method

Role

Basic syntax

Xmldocument.createcomment (data);

Description

Data is a string that contains the data that is placed in the annotation.

Example

Objnewcomment = Xmldoc.createcomment ("This is a comment");
alert (objnewcomment.xml);

Createdocumentfragment method

Role

Creates an empty file fragment object.

Basic syntax

Xmldocument.createdocumentfragment ();

Description

A new file fragment was created but not added to the file tree. To add a fragment to the file tree, you must use the Insert method, such as InsertBefore, ReplaceChild, or appendchild.

Example

Objnewfragment = Xmldoc.createdocumentfragment ();
alert (objnewfragment.xml);

CreateElement method

Role

Creates an element with the specified name.

Basic syntax

Xmldocument.createelement (TagName);

Description

TagName is a case-sensitive string that specifies the new element name.

Example

Objnewelement = Xmldoc.createelement ("to");
alert (objnewelement.xml);

Createentityreference method

Role

Creates an entity that references the specified name.

Basic syntax

Xmldocument.createentityreference (name);

Description

Name is a case-sensitive string that specifies the name of the new entity reference. A new entity reference was created, but was not added to the file tree. To add an entity reference to the file tree, you must use an insertion method, such as Insertbefore,replacechild, or appendchild.

Example

Objnewer = Xmldoc.createentityreference ("Eref");
alert (objnewer.xml);

CreateNode method

Role

Creates a new node of the specified type, name, and namespace.

Basic syntax

Xmldocument.createnode (type, name, NamespaceURI);

Description

Type is used to confirm the node type to be established, name is a string to confirm the name of the new node, and the prefix of the namespace is optional. NamespaceURI is a string that defines the namespace URI. If the prefix is contained in the name parameter, the node is established in the NamespaceURI text with the specified prefix. If you do not include a prefix, the specified namespace is considered a preset namespace.

Example

Objnewnode = Xmldoc.createnode (1, "to", "");
alert (objnewnode.xml);

Createprocessinginstruction method

Role

Create a new processing instruction that contains the specified targets and data.

Basic syntax

Xmldocument.createprocessinginstruction (target, data);

Description

Target is a string that represents the target, name, or processing instruction. Data is the value that represents the processing instruction. A new processing instruction was created, but was not added to the file tree. To add processing instructions to the file tree, you must use the Insert method, for example: InsertBefore, ReplaceChild, or appendchild.

Example

OBJNEWPI =xmldoc.createprocessinginstruction (' XML ', ' version= ' 1.0 ");
alert (objnewpi.xml);

createTextNode method

Role

Creates a new text node and contains the specified data.

Basic syntax

Xmldocument.createtextnode (data);

Description

Data is a string representing the new text node. A new text node was created, but not added to the file tree. To add a node to the file tree, you must use the Insert method, such as Insertbefore,replacechild or appendchild.

Example

Objnewtextnode = Xmldoc.createtextnode ("This is a text node.");
alert (objnewtextnode.xml);

getElementsByTagName method

Role

Returns the collection of elements for the specified name.

Basic syntax

objNodeList = Xmldocument.getelementsbytagname (tagname);

Description

TagName is a string that represents the element volume label name that was found. Use tagname "*" to return all elements found in the file.

Example

objNodeList = Xmldoc.getelementsbytagname ("*");
Alert (Objnodelist.item (1). xml);

HasChildNodes method

Role

If the specified node has one or more child nodes, the return value is true.

Basic syntax

Boolvalue = Xmldocumentnode.haschildnodes ();

Description

Returns a value of False if the node has a child node return value of True.

Example

Boolvalue = XmlDoc.documentElement.hasChildNodes ();
alert (boolvalue);

InsertBefore method

Role

Inserts a child node before the specified node.

Basic syntax

Objdocumentnode = Xmldocumentnode.insertbefore (newchild,refchild);

Description

Newchild is an object that contains the address of the new child node, Refchild is the address of the reference node. The new child node is inserted before the reference node. If the Refchild parameter is not included, the new child node is inserted at the end of the list of child nodes.

Example

Objrefnode = xmldoc.documentelement;
alert (xmldoc.xml);
Objnewnode = Xmldoc.createcomment ("This is a comment");
Xmldoc.insertbefore (Objnewnode, Objrefnode);
alert (xmldoc.xml);

Load method

Role

Represents a file that is loaded from a specified location.

Basic syntax

boolvalue = xmldocument.load (URL);

Description

The URL contains a string containing the URL of the file to be loaded. If the file is loaded successfully, the return value is true. If the load fails, the return value is false.

Example

Boolvalue = Xmldoc.load ("Lsta_1.xml");
alert (boolvalue);

Loadxml method

Role

Loads a fragment of an XML file or string.

Basic syntax

Boolvalue = Xmldocument.loadxml (xmlstring);

Description

XMLString is a string that contains the XML literal code.

Example

xmlstring = "<GREETING><MESSAGE>Hello!</MESSAGE></GREETING>";
Boolvalue = Xmldoc.loadxml (xmlstring);
alert (boolvalue);

Nodefromid method

Role

Returns the node with the node ID that matches the specified value.

Basic syntax

Xmldocumentnode = Xmldocument.nodefromid (idstring);

Description

Idstring is a string containing the ID value. The conforming node must be an ID type. If so, an object is returned, and NULL is returned if the operation fails.

Example

Objdocumentnode = Xmldoc.nodefromid ("to");
alert (Objdocumentnode);

Parsed method

Role

Verifies that the specified node (nodes) and its derived child nodes (descendants) have been parsed.

Basic syntax

Boolvalue = xmldocumentnode.parsed ();

Description

If all nodes have been parsed, the return value is ture, or false if any of the nodes have not been resolved.

Example

Currnode = XmlDoc.documentElement.childNodes.item (0);
Boolvalue = currnode.parsed ();
alert (boolvalue);

RemoveChild method

Role

Removes the specified node from the node manifest.

Basic syntax

Objdocumentnode = Xmldocumentnode.removechild (oldchild);

Description

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

Example

Objremovenode = XmlDoc.documentElement.childNodes.item (3);
alert (xmldoc.xml);
XmlDoc.documentElement.removeChild (Objremovenode);
alert (xmldoc.xml);

ReplaceChild method

Role

The replacement of the specified old child node is the new child node provided.

Basic syntax

Objdocumentnode = Xmldocumentnode.replacechild (newchild,oldchild);

Description

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

Example

Objoldnode = XmlDoc.documentElement.childNodes.item (3);
Objnewnode = xmldoc.createcomment ("I ' ve replaced the BCC element.") ;
alert (xmldoc.xml);
XmlDoc.documentElement.replaceChild (Objnewnode,objoldnode);
alert (xmldoc.xml);

SelectNodes method

Role

Returns all nodes that conform to the provided style (pattern).

Basic syntax

Objdocumentnodelist = Xmldocumentnode.selectnodes (patternstring);

Description

Patternstring is a string containing the XSL style. This method returns the node manifest object, which contains the node that conforms to the style. If no nodes are met, the list of Go home is passed.

Example

Objnodelist=xmldoc.selectnodes ("/");
Alert (Objnodelist.item (0). xml);

selectSingleNode returns the first node that conforms to the style.

Role

Returns the first node that conforms to the style.

Basic syntax

Objdocumentnode = Xmldocumentnode.selectsinglenode (patternstring);

Description

Patternstring is a string containing the XSL style. This method returns the first conforming node object, or null if no nodes are met.

Example

Objnode = Xmldoc.selectsinglenode ("EMAIL/BCC");
alert (objnode.xml);

Transformnode method

Role

Use the provided style sheet to process the node and its child nodes.

Basic syntax

Strtransformeddocument = Xmldocumentnode.transformnode (stylesheet);

Description

Stylesheet is an XML file or fragment that contains the XSL elements responsible for node transformation work. This method returns a string containing the result of the transformation.

Example

var style = new ActiveXObject ("Microsoft.XMLDOM");
Style.load ("lsta_49.xsl");
Strtransform = Xmldoc.transformnode (style.documentelement);
alert (strtransform);



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.