XML DOM - The Node Object

XML DOM - The Node Object

The Node Object

The Node object represents a single node in the document tree.

A node can be an element node, an attribute node, a text node, or any other of the node types explained in the Node Types chapter.

Notice that while all objects inherits the Node properties / methods for dealing with parents and children, not all objects can have parents or children. For example, Text nodes may not have children, and adding children to such nodes results in a DOM error.

IE: Internet Explorer, F: Firefox, O: Opera, W3C: World Wide Web Consortium (Internet Standard)

Node Object Properties

PropertyDescriptionIEFOW3C
baseURIReturns the absolute base URI of a nodeNo1NoYes
childNodesReturns a NodeList of child nodes for a node519Yes
firstChildReturns the first child of a node519Yes
lastChildReturns the last child of a node519Yes
localNameReturns the local part of the name of a nodeNo19Yes
namespaceURIReturns the namespace URI of a nodeNo19Yes
nextSiblingReturns the node immediately following a node519Yes
nodeNameReturns the name of a node, depending on its type519Yes
nodeTypeReturns the type of a node519Yes
nodeValueSets or returns the value of a node, depending on its type519Yes
ownerDocumentReturns the root element (document object) for a node519Yes
parentNodeReturns the parent node of a node519Yes
prefixSets or returns the namespace prefix of a nodeNo19Yes
previousSiblingReturns the node immediately before a node519Yes
textContentSets or returns the textual content of a node and its descendantsNo1NoYes
textReturns the text of a node and its descendants. IE-only property5NoNoNo
xmlReturns the XML of a node and its descendants. IE-only property5NoNoNo

Node Object Methods

MethodDescriptionIEFOW3C
appendChild()Adds a new child node to the end of the list of children of a node519Yes
cloneNode()Clones a node519Yes
compareDocumentPosition()Compares the document position of two nodesNo1NoYes
getFeature(feature,version)Returns a DOM object which implements the specialized APIs of the specified feature and version  NoYes
getUserData(key)Returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key  NoYes
hasAttributes()Returns true if a node has any attributes, otherwise it returns falseNo19Yes
hasChildNodes()Returns true if a node has any child nodes, otherwise it returns false519Yes
insertBefore()Inserts a new child node before an existing child node519Yes
isDefaultNamespace(URI)Returns whether the specified namespaceURI is the default  NoYes
isEqualNode()Checks if two nodes are equalNoNoNoYes
isSameNode()Checks if two nodes are the same nodeNo1NoYes
isSupported(feature,version)Returns whether a specified feature is supported on a node  9Yes
lookupNamespaceURI()Returns the namespace URI matching a specified prefixNo1NoYes
lookupPrefix()Returns the prefix matching a specified namespace URINo1NoYes
normalize()Puts all text nodes underneath a node (including attributes) into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes519Yes
removeChild()Removes a child node519Yes
replaceChild()Replaces a child node519Yes
setUserData(key,data,handler)Associates an object to a key on a node  NoYes

« PreviousNext Chapter »
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值