JS node knowledge in detail _ basic knowledge

Source: Internet
Author: User
Recently, it was found that the DOMDocument object is very important, and XMLHTTP is also important to note that case sensitivity must not be mistaken.
Attribute:
Attribute list of the Attributes storage node (read-only)
List of child nodes of the childNodes storage node (read-only)
DataType returns the Data Type of this node
Definition defines nodes in DTD or XML mode (read-only)
Doctype specifies the file type node (read-only)
DocumentElement returns the root element of the document (read/write)
FirstChild returns the first child node of the current node (read-only)
Implementation returns the 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: return the node name (read-only)
NodeType return node type (read-only)
NodeTypedValue stores node values (read/write)
NodeValue returns the node text (read/write)
OwnerDocument returns the root document containing this node (read-only)
ParentNode returns the parent node (read-only)
Parsed: returns whether the node and Its subnodes have been Parsed (read-only)
Prefix returns the namespace Prefix (read-only)
PreserveWhiteSpace specifies whether to retain white space (read/write)
Previussibling returns the previous sibling node of this node (read-only)
Text returns the Text content of the node and its descendants (read/write)
Url returns the URL of the recently loaded XML document (read-only)
Xml returns the XML Representation of the node and its descendants (read-only)
Method:
AppendChild adds a new subnode to the current node, which is placed after the last subnode
CloneNode returns the copy of the current node
CreateAttribute
CreateCDATASection create CDATA segments that contain the given data
CreateComment create a comment Node
CreateDocumentFragment create a DocumentFragment object
CreateElement: Create an element node
CreateEntityReference: Create an EntityReference object
CreateNode creates nodes of the given type, name, and namespace.
CreatePorcessingInstruction
CreateTextNode: Create a text node that includes the given data
GetElementsByTagName returns the set of elements with the specified name.
HasChildNodes: returns whether the current node has subnodes.
InsertBefore inserts a subnode before a specified Node
Load import the XML document at the specified position
LoadXML import the XML document of the specified string
RemoveChild deletes a specified subnode from the subnode list.
ReplaceChild replaces the specified child node from the child node list
Save the XML file to the specified Node
SelectNodes matches the specified node and returns the list of matched nodes.
SelectSingleNode matches the specified node and returns the first matching node.
TransformNode converts nodes and their descendants using the specified style table.
TransformNodeToObject: Use the specified style sheet to convert nodes and their descendants to objects.
DOM (Document Object Model)
The introduction of the DOM (Document Object Model) concept makes HTML even more powerful. However, some friends who are familiar with DHTML are still a bit difficult, just because the current manual is not very scientific and is written by letters.
In fact, the most important thing in DOM is to know the relationship between nodes (between node andnode). Do not read the DOM in DHTML from start to end.
Some attributes and methods do you have the "Unforgettable" skills of Zhang song during the Three Kingdoms? No, let me analyze it:
In fact, what DOM teaches us is a hierarchical structure. You can think of it as a tree structure, just like our directory. A root directory contains sub-directories and sub-directories.
Directory ......
Root Node:
DOM calls every object in the hierarchy a NODE. Take HTML hypertext markup language as an example: a root of the entire document is, Which can be used in DOM
Document.doc umentElement, which is the ROOT node of the entire node tree)
Subnode:
Generally, the maximum subnode below the root node is the main document area.To access the body tag, write the following in the script:
Document. body
All text and HTML tags in the body area are document nodes, which are called text nodes and element nodes (or tag nodes) respectively. We all know that HTML is just text,
No matter what the web page is, it must be composed of these two nodes, and it can only be composed of these two nodes.
Relationship between nodes:
The relationship between nodes is also one of the most important joints in DOM. To correctly reference a Node object, you must understand the description of each node in the node tree. In DHTML,
The Javascript script uses a complete set of methods and attributes of each node object to describe another Node object.
Absolute reference of a node:
Return the root node of the document
Document.doc umentElement
Returns the tag node that is being attacked in the current document.
Document. activeElement
Back to the source node with the mouse removed
Event. fromElement
Back to the source node
Event. toElement
Returns the source node of the activation event.
Event. srcElement
Relative reference of a node: (set the current peer node to a node)
Back to parent node
Node. parentNode
Node. parentElement
Return the child node set (including text nodes and label nodes)
Node. childNodes
Returns a set of child tag nodes.
Node. children
Returns a set of child text nodes.
Node. textNodes
Returns the first subnode.
Node. firstChild
Returns the last subnode.
Node. lastChild
Returns the same node
Node. nextSibling
Returns the same node.
Node. previussibling
Node operations: (set the current node to node)
Add a label node handle:
Document. createElement (sNode) // The name of the node label to be added. For example, newnode = document. createElement ("p ");
Add a node:
Append a subnode:
Node. appendChild (oNode) // node handle newly added by oNode, for example, node. appendChild (newnode)
Application label Node
Node. applyElment (oNode, sWhere) // node handle newly added by oNode. sWhere has two values: outside/inside, which are added to the current node or inside.
Insert Node
Inode. insertBefore ()
Node. insertAdjacentElement ()
Node. replaceAdjacentText ()
Modify a node:
Delete a node
Node. remove ()
Node. removeChild ()
Node. removeNode ()
Replace Node
Node. replaceChild ()
Node. replaceNode ()
Node. swapNode ()
, Copy node:
Return copy node reference
Node. cloneNode (bAll) // bAll is a Boolean value. true/false indicates whether to clone all child nodes of the node.
, Node Information
Include a node?
Node. contains ()
Indicates whether a subnode exists.
Node. hasChildNodes ()
**************************************** ***************
The following describes how to operate xml in javascript.
Related Article

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.