Note that the case must not be mistaken.
Properties:
Attributes a list of properties for storage nodes (read-only)
ChildNodes List of child nodes for storage nodes (read-only)
DataType returns the data type of this node
Definition of a node given in a DTD or XML schema (read-only)
Doctype Specify document Type node (read-only)
DocumentElement returns the root element of the document (Readable and writable)
FirstChild returns the first child node of the current node (read-only)
Implementation return Xmldomimplementation Object
LastChild returns the last child node of the current node (read-only)
NextSibling returns the next sibling node of the current node (read-only)
NodeName returns the name of the node (read-only)
NodeType returns the type of the node (read-only)
nodeTypedValue Storage node value (readable and writable)
NodeValue returns the text of the node (readable and writable)
Ownerdocument returns the root document containing this node (read-only)
ParentNode Return parent node (read only)
Parsed returns whether this node and its child nodes have been resolved (read-only)
Prefix return namespace prefix (read only)
PRESERVEWHITESPACE Specifies whether to leave blank (read-write)
PreviousSibling returns the previous sibling node of this node (read-only)
Text returns the textual content of this node and its descendants (readable and writable)
URL returns the URL of the most recently loaded XML document (read-only)
XML representation of the XML return node and its descendants (read-only)
Method:
AppendChild adds a new child node to the current node and places it after the last child node
CloneNode returns the copy of the current node
CreateAttribute Create a new property
Createcdatasection Create a CDATA segment that includes a given data
Createcomment Create a comment node
Createdocumentfragment Create DocumentFragment Object
CreateElement Create an element node
Createentityreference Create EntityReference Object
CreateNode Create a node for a given type, name, and namespace
Createporcessinginstruction Create operation instruction node
createTextNode Create a text node that includes a given data
getElementsByTagName returns the collection of elements of the specified name
HasChildNodes returns whether the current node has child nodes
InsertBefore inserts a child node before the specified node
Load import XML document at specified location
Loadxml an XML document that imports a specified string
RemoveChild deletes the specified child node from the list of child nodes
ReplaceChild to replace the specified child node from the list of child nodes
Save saves the XML file to the specified node
SelectNodes a specified match to the node and returns a list of matching nodes
selectSingleNode a specified match to the node and returns the first matching node
Transformnode the node and its descendants using the specified style sheet
transformNodeToObject converts a node and its descendants to an object using the specified style sheet
DOM (Document Object model)
The introduction of the DOM (Document Object model) concept, which makes HTML even more powerful, but some of the DHTML friends are still somewhat scratched, just because the current manual is not very scientific writing, is by letter
To divide, inconvenient to consult. In fact, the most important thing in DOM is to master the relationship between nodes and nodes (between node Andnode), to learn the DOM in DHTML. Don't look through the
Some properties and methods, you have three Kingdoms when ZS "photographic memory" ability? No, then listen to me to analyze:
What Dom teaches us is a hierarchy that you can understand as a tree structure, like our directory, a root directory, a subdirectory under the root directory, and a child under a subdirectory.
Directory......
root node:
Dom refers to each object in the hierarchy as a node, an example of an HTML Hypertext Markup Language: One root of the entire document is <HTML>, which can be used in the DOM
Document.documentelement to access it, which is the root node of the entire node tree (root)
child nodes:
In the general sense of the node, the root node below the largest child node is the main document area <body>, to access the body tag, in the script should write:
Document.body
All text and HTML tags within the body area are the nodes of the document, called text nodes, element nodes (or tag nodes), and you know that HTML is just text,
No matter what kind of Web page must be composed of these two nodes, it can only be composed of these two nodes
The relationship between nodes:
The relationship between the nodes is also one of the most important joints in the DOM, how to correctly refer to the node object, it is necessary to understand the node tree each node of each other description way, in DHTML,
JavaScript scripts use a set of methods and attributes for each node object to describe another node object.
An absolute reference to a node:
Returns the root node of a document
Document.documentelement
Returns the tab node that is being clicked in the current document
Document.activeelement
Returns the source node from which the mouse is moved
Event.fromelement
Returns the source node where the mouse is moved
Event.toelement
Returns the source node of the activation event
Event.srcelement
The relative reference of the node: (set node for current nodes)
Return parent Node
Node.parentnode
Node.parentelement
Returns a collection of child nodes (including text nodes and label nodes)
Node.childnodes
Return child label Node collection
Node.children
Returns a collection of child text nodes
Node.textnodes
Returns the first child node
Node.firstchild
Returns the last child node
Node.lastchild
Returns the same genus next node
Node.nextsibling
Returns the same last node
Node.previoussibling
The various operations of the node: (Set the current node to nodes)
New label node handle:
Document.createelement (Snode)//parameter is the node tag name to be added, example: Newnode=document.createelement ("div");
, adding nodes:
Append child nodes:
Node.appendchild (onode)//onode new node handle for a living, example: Node.appendchild (NewNode)
Apply Label node
Node.applyelment (Onode,swhere)//onode A new node handle for a living, Swhere has two values: Outside/inside, added to the current node or inside
Insert Node
Inode.insertbefore ()
Node.insertadjacentelement ()
Node.replaceadjacenttext ()
, modify the node:
Delete a node
Node.remove ()
Node.removechild ()
Node.removenode ()
Replacing nodes
Node.replacechild ()
Node.replacenode ()
Node.swapnode ()
, Replication nodes:
Returns a replication Replication node reference
Node.clonenode (BALL)//ball is a Boolean value true/false whether to clone all child nodes of the node
, node information
Whether to include a node
Node.contains ()
Whether there are child nodes
Node.haschildnodes ()
*******************************************************
The following is JavaScript manipulating XML
<script language= "JavaScript" >
<!--
var doc = new ActiveXObject ("Msxml2.domdocument"); Ie5.5+,createobject ("Microsoft.XMLDOM")
Loading documents
Doc.load ("B.xml");
To create a file header
var p = doc.createprocessinginstruction ("xml", "version= ' 1.0 ' encoding= ' gb2312 '");
Add File Headers
Doc.appendchild (P);
To get the root contact when loading directly
var root = doc.documentelement;
Create root contacts in two ways
var root = doc.createelement ("Students");
var root = Doc.createnode (1, "Students", "");
Creating Child contacts
var n = doc.createnode (1, "Ttyp", "");
Specify Child Contact text
N.text = "This is a test";
Create Sun Contact
var o = doc.createelement ("Sex");
O.text = "male"; Specify its text
Creating properties
var r = doc.createattribute ("id");
r.value= "Test";
Add properties
N.setattributenode (R);
Create a second property
var r1 = Doc.createattribute ("class");
R1.value= "TT";
Add properties
N.setattributenode (R1);
Delete Second Property
N.removeattribute ("class");
Add Sun Contact
N.appendchild (o);
Add text Contacts
N.appendchild (Doc.createtextnode ("This is a text node.");
Add a Comment
N.appendchild (Doc.createcomment ("This is a comment\n"));
Add Child contacts
Root.appendchild (n);
Copy Contacts
var m = N.clonenode (true);
Root.appendchild (m);
Delete a contact
Root.removechild (root.childnodes (0));
Create a data segment
var c = doc.createcdatasection ("This is a CDATA");
C.text = "Hi,cdata";
Adding data segments
Root.appendchild (c);
Add Root Contact
Doc.appendchild (root);
Find Contacts
var a = Doc.getelementsbytagname ("Ttyp");
var a = Doc.selectnodes ("//ttyp");
Show the properties of the modified contact
for (var i= 0;i<a.length;i++)
{
alert (a[i].xml);
for (Var j=0;j<a[i].attributes.length;j++)
{
alert (a[i].attributes[j].name);
}
}
modifying nodes, using XPath to locate nodes
var B = Doc.selectsinglenode ("//ttyp/sex");
B.text = "female";
alert (doc.xml);
XML save (required on server, client with FSO)
Doc.save ();
View the root contact XML
if (n)
{
alert (n.ownerdocument.xml);
}
-->
</script>