XML DOM Objects' Properties and Methods in W3C&IE

The Node Object

W3C Properties

Property Description
attributes Returns a NamedNodeMap containing all attributes for this node
childNodes Returns a NodeList containing all the child nodes for this node
firstChild Returns the first child node for this node
lastChild Returns the last child node for this node
nextSibling Returns the next sibling node. Two nodes are siblings if they have the same parent node
nodeName Returns the nodeName, depending on the type
nodeType Returns the nodeType as a number
nodeValue Returns, or sets, the value of this node, depending on the type
ownerDocument Returns the root node of the document
parentNode Returns the parent node for this node
previousSibling Returns the previous sibling node. Two nodes are siblings if they have the same parent node

W3C Methods

Method Description
appendChild(newChild) Appends the node newChild at the end of the child nodes for this node
cloneNode(boolean) Returns an exact clone of this node. If the boolean value is set to true, the cloned node contains all the child nodes as well
hasChildNodes() Returns true if this node has any child nodes
insertBefore(newNode,refNode) Inserts a new node, newNode, before the existing node, refNode
removeChild(nodeName) Removes the specified node, nodeName
replaceChild(newNode,oldNode) Replaces the oldNode, with the newNode

IE5 Node Properties and Methods

The node object has some properties and methods that are defined in Internet Explorer 5 only:

IE5 Properties

Property Description
basename Returns the nodeName without the namespaces
dataType Returns, or sets, the dataType for this node
definition  
nodeTypeString Returns the nodeType as a string
nodeTypedValue  
specified Returns whether the nodeValue is specified in the DTD/Schema or not
text Returns, or sets, the text for this node and all its child nodes
xml Returns, or sets, the xml for this node and all its child nodes

IE5 Methods

Method Description
selectNodes(pattern)  
selectSingleNode(pattern)  
transformNode(stylesheet) Processes the node and its childNodes with the specified XSL stylesheet, and returns the result



The NodeList object

W3C Properties

Property Description
length Returns the number of nodes in a nodeList

W3C Methods

Method Description
item Returns a specific node in the nodeList

IE5 NodeList Methods
      The nodeList object has some methods that are defined in Internet Explorer 5 only:
IE5 Properties

Property Description
nextNode() Returns the next object in the node list
reset() Resets the pointer to the first node in the nodeList


 The Document object

W3C Properties

Property Description
documentElement Returns the root element of the document
doctype Returns the DTD or Schema for the document. 
implementation Returns the implementation object for this particular document

W3C Methods

Method Description
createAttribute(attributeName) Creates an attribute node with the specified attribute name
createCDATASection(text) Creates a CDATASection, containing the specified text
createComment(text) Creates a comment node, containing the specified text
createDocumentFragment() Creates an empty documentFragment object
createElement(tagName) Creates an element with the specified tagName
createEntityReference(referenceName) Creates an entityReference with the specified referenceName
createProcessingInstruction(target,text) Creates a processingInstruction node, containing the specified target and text
createTextNode(text) Creates a text node, containing the specified text
getElementsByTagName(tagName) Returns the specified node, and all its child nodes, as a nodeList


The Element object

W3C Properties

Property Description
tagName Returns, or sets the name of the node

W3C Methods

Method Description
getAttribute(attributeName) Returns the value of the specified attribute
getAttributeNode(attributeName) Returns the specified attribute node as an object
getElementsByTagName(tagName) Returns the specified node, and all its child nodes, as a nodeList
normalize() Puts the text nodes for this element, and its child nodes, into one text node, returns nothing
removeAttribute(attributeName) Removes the specified attribute's value. If the attribute has a default value this value is inserted
removeAttributeNode(attributeNode) Removes the specified attribute node. If the attribute node has a default value, this attribute is inserted
setAttribute(attributeName, attributeValue) Inserts a new attribute
setAttributeNode(attributeNodeName) Inserts a new attribute node


The Attr object

W3C Properties

Property Description
name Sets or returns the name of the attribute
specified Returns a boolean value indicating if the node's value is set in the document or not
value Sets or returns the value of the attribute


The Text object

The text object represents the text inside an element as a node. The method of the text object is listed below:

W3C Method

Method Description
splitText(number) Splits the text at the specified character, and returns the rest of the text

posted on 2004-08-19 14:01  9yue  阅读(707)  评论(0)    收藏  举报