Intro

The Element nodes represents elements in documents. EG: An Element node may represent <p> in XHTML or <book> in XML.

An Element node has a nodeType=1.

A Element node may have the following kinds of child nodes: Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference.

Properties

  • schemaTypeInf. 'The type information associated with this element.'. DOM 3+.
  • tagName. 'The name of the element. If Node.localName is different from null, this attribute is a qualified name.'

Methods

  • getAttribute(name). 'Retrieves an attribute value by name.'.
  • getAttributeNS(namespaceURI,localName). 'Retrieves an attribute value by local name and namespace URI. ... applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.'. DOM 2+.
  • getAttributeNode(name). 'Retrieves an attribute node by name.'
  • getAttributeNodeNS(namespaceURI,localName). 'Retrieves an Attr node by local name and namespace URI. ... applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.'. DOM 2+.
  • getElementsByTagName(name). 'Returns a NodeList of all descendant Elements with a given tag name, in document order.'
  • getElementsByTagNameNS(namespaceURI,localName). 'Returns a NodeList of all the descendant Elements with a given local name and namespace URI in document order.'. DOM 2+.
  • hasAttribute(name). 'Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise.' DOM 2+.
  • hasAttributeNS(namespaceURI,localName).'Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise. ... applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.'. DOM 2+.
  • removeAttribute(name). 'Removes an attribute by name. If a default value for the removed attribute is defined in the DTD, a new attribute immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use Document.normalizeDocument() to guarantee this information is up-to-date. If no attribute with this name is found, this method has no effect.'.
  • removeAttributeNS(namespaceURI,localName). 'Removes an attribute by local name and namespace URI. If a default value for the removed attribute is defined in the DTD, a new attribute immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use Document.normalizeDocument() to guarantee this information is up-to-date. If no attribute with this local name and namespace URI is found, this method has no effect. Per [XML Namespaces], applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.'. DOM 2+.
  • removeAttributeNode(oldAttr). 'Removes [and returns] the specified attribute node. If a default value for the removed Attr node is defined in the DTD, a new node immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use Document.normalizeDocument() to guarantee this information is up-to-date.'
  • setAttribute(name,value). 'Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNode to assign it as the value of an attribute. To set an attribute with a qualified name and namespace URI, use the setAttributeNS method.'
  • setAttributeNS(namespaceURI,qualifiedName,value). 'Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute. Per [XML Namespaces], applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.' DOM 2+.
  • setAttributeNode(newAttr). 'Adds [and returns] a new attribute node. If an attribute with that name (nodeName) is already present in the element, it is replaced by the new one. Replacing an attribute node by itself has no effect.'
  • setAttributeNS(namespaceURI,qualifiedName,value). 'Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute.' DOM 2+.
  • setIdAttribute(name,isId). 'If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute. This affects the value of Attr.isId and the behavior of Document.getElementById, but does not change any schema that may be in use, in particular this does not affect the Attr.schemaTypeInfo of the specified Attr node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute.'. DOM 3+.
  • setIdAttributeNS(namespaceURI,localName,isId). 'If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute. This affects the value of Attr.isId and the behavior of Document.getElementById, but does not change any schema that may be in use, in particular this does not affect the Attr.schemaTypeInfo of the specified Attr node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute.'. DOM 3+.
  • setIdAttributeNode(idAttr,isId). 'If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute. This affects the value of Attr.isId and the behavior of Document.getElementById, but does not change any schema that may be in use, in particular this does not affect the Attr.schemaTypeInfo of the specified Attr node. Use the value false for the parameter isId to undeclare an attribute for being a user-determined ID attribute.'. DOM 3+.


GeorgeHernandez.comSome rights reserved