node.md

May 9, 2016 ยท View on GitHub

Layers of nodes Back

  • In Dom,

    • Document: the top node
    • DocumentType: <!DOCTYPE>
    • DocumentFragment: can store other nodes like Document.TE
    • Element: contents between a tag(nodes with properties and sub-nodes).
    • Attr: a pair of properties and values
    • Text: contents between a tag in XML(nodes with only text inside).
    • CDataSection: <![CDATA[]]>, can only conclude nodes of text.
    • Entity: define an entity like <!ENTITY foo "foo">.
    • EntityReference: a reference to an entity like &nbsp;.
    • ProcessingInstruction: stand for a PI, like <?target data?>.
    • Comment: XML comment.
    • Notation: symbols in Document Type Definition(DTD).
  • Properties or Methods of nodes:

    • NodeList: a list of child nodes
    • NamedNodeMap: a map of paired keys with attributes and values
Properties/MethodsTypes/Returned typesDescriptions
nodeNameStringthe name of the node
nodeValueStringthe value of the node
nodeTypeNumberthe type of the node
ownerDocumentDocumentthe owner document of the node
firstChildNodethe first node in the list - childNodes
lastChildNodethe last node in the list - childNodes
childNodesNodeLista list of all the child nodes
previousSiblingNodethe previous brother node
nextSiblingNodethe next brother node
attributesNamedNodeMapconclude the Attr which can represent the properties of this node
hasChildNodes()Booleanreturn true when there is a child node
appendChild(Node)Nodeadd a node into the list - childNodes
removeChild(Node)Noderemove a node from the list - childNodes
replaceChild(newnode, oldnode)Nodereplace an oldnode from the list - childNodes with the newnode
insertBefore(newnode, refnode)Nodeadd a newnode into the list - childNodes before the refnode