Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1793655
  • 博文数量: 438
  • 博客积分: 9799
  • 博客等级: 中将
  • 技术积分: 6092
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-25 17:25
文章分类

全部博文(438)

文章存档

2019年(1)

2013年(8)

2012年(429)

分类: Python/Ruby

2012-05-13 02:00:39

NodeThe Node object represents a node in the HTML document.
PropertyDescriptionDOM
attributesReturns a collection of a node's attributes1
baseURIReturns the absolute base URI of a node3
childNodesReturns a NodeList of child nodes for a node1
firstChildReturns the first child of a node1
lastChildReturns the last child of a node1
localNameReturns the local part of the name of a node2
namespaceURIReturns the namespace URI of a node2
nextSiblingReturns the next node at the same node tree level1
nodeNameReturns the name of a node, depending on its type1
nodeTypeReturns the type of a node1
nodeValueSets or returns the value of a node, depending on its type1
ownerDocumentReturns the root element (document object) for a node2
parentNodeReturns the parent node of a node1
prefixSets or returns the namespace prefix of a node2
previousSiblingReturns the previous node at the same node tree level1
textContentSets or returns the textual content of a node and its descendants3
MethodDescriptionDOM
appendChild()Adds a new child node, to the specified node, as the last child node1
cloneNode()Clones a node1
compareDocumentPosition()Compares the document position of two nodes1
getFeature(feature,version)Returns a DOM object which implements the specialized APIs of the specified feature and version3
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 key3
hasAttributes()Returns true if a node has any attributes, otherwise it returns false2
hasChildNodes()Returns true if a node has any child nodes, otherwise it returns false1
insertBefore()Inserts a new child node before a specified, existing, child node1
isDefaultNamespace()Returns true if the specified namespaceURI is the default, otherwise false3
isEqualNode()Checks if two nodes are equal3
isSameNode()Checks if two nodes are the same node3
isSupported()Returns true if a specified feature is supported on a node, otherwise false2
lookupNamespaceURI()Returns the namespace URI matching a specified prefix3
lookupPrefix()Returns the prefix matching a specified namespace URI3
normalize()Joins adjacent text nodes and removes empty text nodes2
removeChild()Removes a child node1
replaceChild()Replaces a child node1
setUserData(key,data,handler)Associates an object to a key on a node3

Node typeDescriptionChildren
1ElementRepresents an elementElement, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
2AttrRepresents an attributeText, EntityReference
3TextRepresents textual content in an element or attributeNone
4CDATASectionRepresents a CDATA section in a document (text that will NOT be parsed by a parser)None
5EntityReferenceRepresents an entity referenceElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
6EntityRepresents an entityElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
7ProcessingInstructionRepresents a processing instructionNone
8CommentRepresents a commentNone
9DocumentRepresents the entire document (the root-node of the DOM tree)Element, ProcessingInstruction, Comment, DocumentType
10DocumentTypeProvides an interface to the entities defined for the documentNone
11DocumentFragmentRepresents a "lightweight" Document object, which can hold a portion of a documentElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
12NotationRepresents a notation declared in the DTDNone
Node typenodeName returnsnodeValue returns
1Elementelement namenull
2Attrattribute nameattribute value
3Text#textcontent of node
4CDATASection#cdata-sectioncontent of node
5EntityReferenceentity reference namenull
6Entityentity namenull
7ProcessingInstructiontargetcontent of node
8Comment#commentcomment text
9Document#documentnull
10DocumentTypedoctype namenull
11 DocumentFragment#document fragmentnull
12Notationnotation namenull
NodeTypeNamed Constant
1ELEMENT_NODE
2ATTRIBUTE_NODE
3TEXT_NODE
4CDATA_SECTION_NODE
5ENTITY_REFERENCE_NODE
6ENTITY_NODE
7PROCESSING_INSTRUCTION_NODE
8COMMENT_NODE
9DOCUMENT_NODE
10DOCUMENT_TYPE_NODE
11DOCUMENT_FRAGMENT_NODE
12NOTATION_NODE


NodeList 

The NodeList object represents an ordered collection of nodes.

The nodes in the NodeList can be accessed through their index number (starting from 0).

A NodeList object could be a Node's collection of child nodes.


PropertyDescriptionDOM
lengthReturns the number of nodes in the collection1
MethodDescriptionDOM
item()Returns the node at the specified index in a node list1


NamedNodeMap

The NamedNodeMap object represents an unordered collection of nodes.

The nodes in the NamedNodeMap can be accessed through their name.

A NamedNodeMap object could be a Node's collection of attributes.


PropertyDescriptionDOM
lengthReturns the number of nodes in the collection1
MethodDescriptionDOM
getNamedItem()Returns the specified node (by name)1
getNamedItemNS()Returns the specified node (by name and namespace)2
item()Returns the node at the specified index in the namedNodeMap1
removeNamedItem()Removes the specified node (by name)1
removeNamedItemNS()Removes the specified node (by name and namespace)2
setNamedItem()Sets the specified node (by name)1
setNamedItemNS()Sets the specified node (by name and namespace)2


Document

The Document object is the root of a document tree.

The Document object gives us access to the document's data.

Since element nodes, text nodes, attributes, comments, etc. cannot exist outside the document, the Document object contains methods to create these objects. All Node objects have a ownerDocument property which associates them with the Document where they were created.


PropertyDescriptionDOM
doctypeReturns the Document Type Declaration associated with the document1
documentElementReturns the Document Element of the document (the HTML element)1
documentURISets or returns the location of the document3
domConfigReturns the configuration used when normalizeDocument() is invoked3
implementationReturns the DOMImplementation object that handles this document1
inputEncodingReturns the encoding, character set, used for the document3
strictErrorCheckingSets or returns whether error-checking is enforced or not3
xmlEncodingReturns the XML encoding of the XML document3
xmlStandaloneSets or returns whether the XML document is standalone or not3
xmlVersionSets or returns the XML version of the XML document3
MethodDescriptionDOM
adoptNode(node)Adopts a node from another document to this document. Returns the adopted node3
createAttribute()Creates an attribute node1
createAttributeNS(URI,name)Creates an attribute with the specified name and namspaceURI2
createCDATASection()Creates a CDATA node with the specified text. For XML DOM only1
createComment()Creates a Comment node with the specified text1
createDocumentFragment()Creates an empty DocumentFragment node1
createElement()Creates an Element node1
createElementNS()Creates an element with the specified namespace2
createEntityReference()Creates an EntityReference node. For XML DOM only1
createProcessingInstruction()Creates an EntityReference node. For XML DOM only1
createTextNode()Creates a Text node1
getElementById()Returns the element that has the ID attribute with the specified value2
getElementsByTagName()Returns a NodeList containing all elements with the specified tagname1
getElementsByTagNameNS()Returns a NodeList containing all elements with the specified namespaceURI and tagname2
importNode()Imports a node from another document2
normalizeDocument()Removes empty Text nodes, and joins adjacent nodes3
renameNode()Renames the specified node3


Element

The Element object represents an element in the HTML document.

The Element object can have child nodes of type Element, Text, Comment, CDATASection, ProcessingInstruction, and EntityReference.

The Element object can have attributes, which have the node type Attr.


PropertyDescriptionDOM
schemaTypeInfoReturns the type information of the element.3
tagNameReturns the tag name of the element1
MethodDescriptionDOM
getAttribute()Returns the specified attribute value1
getAttributeNS()Returns the specified attribute value, with the specified namespace. For XML DOM only2
getAttributeNode()Returns the specified attribute node1
getAttributeNodeNS()Returns the specified attribute node, with the specified namespace. For XML DOM only3
getElementsByTagName()Returns a collection of all child elements with the specified tagname1
getElementsByTagNameNS()Returns a collection of all child elements with the specified tagname and namespace. For XML DOM only2
hasAttribute()Returns true if the element has the specified attribute, otherwise it returns false2
hasAttributeNS()Returns true if the element has the specified attribute, with the specified namespace, otherwise it returns false. For XML DOM only2
removeAttribute()Removes the specified attribute1
removeAttributeNS()Removes the attribute with the specified name and namespace. For XML DOM only2
removeAttributeNode()Removes the specified attribute node, and returns the removed node1
setAttribute()Sets or changes the specified attribute, to the specified value1
setAttributeNS()Sets or changes the specified attribute, with the specified namespace, to the specified value. For XML DOM only2
setAttributeNode()Sets or changes the specified attribute node1
setAttributeNodeNS()Sets or changes the specified attribute node2
setIdAttribute()
3
setIdAttributeNS()
3
setIdAttributeNode()
3


Attr
PropertyDescriptionDOM
isIdReturns true if the attribute is of type ID, otherwise it returns false3
nameReturns the name of the attribute1
ownerElementReturns the element this attribute belongs to2
schemaTypeInfoReturns the type information of the attribute3
specifiedReturns true if the attribute has been specified, otherwise it returns false1
valueSets or returns the value of the attribute1


阅读(1694) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~