com.aspose.html.dom

Class Element

    • Constructor Detail

      • Element

        public Element(DOMName name,
                       Document doc)

        Initializes a new instance of the Element class.

        Parameters:
        name - The elment name.
        doc - The document.
    • Method Detail

      • getTag

        public Tag getTag()
      • getLocalName

        @DOMNameAttribute(name="localName")
        public String getLocalName()

        Returns the local part of the qualified name of this node. For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as Document.createElement(), this is always null.

        Value: The local part of the qualified name.
        Overrides:
        getLocalName in class Node
      • getNodeName

        public String getNodeName()

        The name of this node, depending on its type.

        Value: The name of the node.
        Specified by:
        getNodeName in class Node
      • getNodeType

        public int getNodeType()

        A code representing the type of the underlying object.

        Value: The code representing the type of the node.
        Specified by:
        getNodeType in class Node
      • getId

        @DOMNameAttribute(name="id")
        public String getId()

        The element's identifier. See the id attribute definition in HTML 4.01.

        Value: The identifier.
      • setId

        @DOMNameAttribute(name="id")
        public void setId(String value)

        The element's identifier. See the id attribute definition in HTML 4.01.

        Value: The identifier.
      • getClassName

        @DOMNameAttribute(name="className")
        public String getClassName()

        The class attribute of the element. This attribute has been renamed due to conflicts with the "class" keyword exposed by many languages. See the class attribute definition in HTML 4.01.

        Value: The class attribute.
      • setClassName

        @DOMNameAttribute(name="className")
        public void setClassName(String value)

        The class attribute of the element. This attribute has been renamed due to conflicts with the "class" keyword exposed by many languages. See the class attribute definition in HTML 4.01.

        Value: The class attribute.
      • getAttributes_Rename_Namesake

        @DOMNameAttribute(name="attributes")
        public NamedNodeMap getAttributes_Rename_Namesake()

        A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

        Value: The attributes map.
      • getAttributeNS

        @DOMNameAttribute(name="getAttributeNS")
         @DOMNullableAttribute
        public String getAttributeNS(String namespaceURI,
                                                                                                       String localName)

        Retrieves an attribute value by local name and namespace URI.

        Parameters:
        namespaceURI - The namespace URI.
        localName - Name of the local.
        Returns:
        Returns attribute
      • setAttribute

        @DOMNameAttribute(name="setAttribute")
        public void setAttribute(String name,
                                                                         String 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

        Parameters:
        name - The attribute name.
        value - The value.
      • setAttributeNS

        @DOMNameAttribute(name="setAttributeNS")
        public void setAttributeNS(String namespaceURI,
                                                                             String qualifiedName,
                                                                             String 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.

        Parameters:
        namespaceURI - The namespace URI.
        qualifiedName - Name of the qualified.
        value - The value.
      • removeAttribute

        @DOMNameAttribute(name="removeAttribute")
        public void removeAttribute(String name)

        Removes an attribute by name.

        Parameters:
        name - The attribute name.
      • removeAttributeNS

        @DOMNameAttribute(name="removeAttributeNS")
        public void removeAttributeNS(String namespaceURI,
                                                                                   String localName)

        Removes an attribute by local name and namespace URI.

        Parameters:
        namespaceURI - The namespace URI.
        localName - Name of the local.
      • hasAttribute

        @DOMNameAttribute(name="hasAttribute")
        public boolean hasAttribute(String name)

        Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise.

        Parameters:
        name - The attribute name.
        Returns:
        true if the specified name has attribute; otherwise, false.
      • hasAttributeNS

        @DOMNameAttribute(name="hasAttributeNS")
        public boolean hasAttributeNS(String namespaceURI,
                                                                                String 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.

        Parameters:
        namespaceURI - The namespace URI.
        localName - Name of the local.
        Returns:
        true if [has attribute NS] [the specified namespace URI]; otherwise, false.
      • getAttributeNode

        @DOMNameAttribute(name="getAttributeNode")
        public Attr getAttributeNode(String name)

        Retrieves an attribute node by name.

        Parameters:
        name - The attribute name.
        Returns:
        Returns attribute value
      • setAttributeNode

        @DOMNameAttribute(name="setAttributeNode")
        public Attr setAttributeNode(Attr newAttr)

        Adds a new attribute node. If an attribute with that name (nodeName) is already present in the element, it is replaced by the new one.

        Parameters:
        newAttr - The new attr.
        Returns:
        Returns attribute
      • removeAttributeNode

        @DOMNameAttribute(name="removeAttributeNode")
        public Attr removeAttributeNode(Attr oldAttr)

        Removes the specified attribute node.

        Parameters:
        oldAttr - The old attr.
        Returns:
        Returns attribute
      • getAttributeNodeNS

        @DOMNameAttribute(name="getAttributeNodeNS")
        public Attr getAttributeNodeNS(String namespaceURI,
                                                                                     String localName)

        Retrieves an Attr node by local name and namespace URI.

        Parameters:
        namespaceURI - The namespace URI.
        localName - Name of the local.
        Returns:
        Returns attribute
      • setAttributeNodeNS

        @DOMNameAttribute(name="setAttributeNodeNS")
        public Attr setAttributeNodeNS(Attr newAttr)

        Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.

        Parameters:
        newAttr - The new attr.
        Returns:
        Returns attribute
      • getElementsByTagName

        @DOMNameAttribute(name="getElementsByTagName")
        public HTMLCollection getElementsByTagName(String name)

        Returns a NodeList of all descendant Elements with a given tag name, in document order.

        Parameters:
        name - The tag name.
        Returns:
        Returns attribute
      • getElementsByTagNameNS

        @DOMNameAttribute(name="getElementsByTagNameNS")
        public HTMLCollection getElementsByTagNameNS(String namespaceURI,
                                                                                                       String localName)

        Returns a NodeList of all the descendant Elements with a given local name and namespace URI in document order.

        Parameters:
        namespaceURI - The namespace URI.
        localName - Name of the local.
        Returns:
        Returns elements
      • remove

        public void remove()

        Removes this instance.

        Specified by:
        remove in interface IChildNode
      • getPreviousElementSibling

        public Element getPreviousElementSibling()

        Returns the previous sibling element node of this element. null if this element has no element sibling nodes that come before this one in the document tree.

        Specified by:
        getPreviousElementSibling in interface IElementTraversal
      • getNextElementSibling

        public Element getNextElementSibling()

        Returns the next sibling element node of this element. null if this element has no element sibling nodes that come after this one in the document tree.

        Specified by:
        getNextElementSibling in interface IElementTraversal
      • getChildElementCount

        public int getChildElementCount()

        Returns the current number of element nodes that are children of this element. 0 if this element has no child nodes that are of nodeType 1.

        Value: The child element count.
        Specified by:
        getChildElementCount in interface IParentNode
        Specified by:
        getChildElementCount in interface IElementTraversal
      • getChildren

        public HTMLCollection getChildren()

        Returns the child elements of current element.

        Value: The children collection
        Specified by:
        getChildren in interface IParentNode
      • cloneNode

        public Node cloneNode(boolean deep)

        Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent (parentNode is null) and no user data.

        Specified by:
        cloneNode in class Node
        Parameters:
        deep - if set to true [deep].
        Returns:
        Returns cloned node
      • querySelectorAll

        public HTMLCollection querySelectorAll(String selector)

        Returns a NodeList of all the Elements in document, which match selector

        Specified by:
        querySelectorAll in interface IParentNode
        Parameters:
        selector - The selector
        Returns:
        HTMLCollection
      • querySelector

        public Element querySelector(String selector)

        Returns the first Element in document, which match selector

        Specified by:
        querySelector in interface IParentNode
        Parameters:
        selector - The selector.
        Returns:
        The matched element
      • getSchemaTypeInfo

        @DOMNameAttribute(name="schemaTypeInfo")
        public TypeInfo getSchemaTypeInfo()

        The type information associated with this element.

        Value: The schema type information.
      • setIdAttribute

        @DOMNameAttribute(name="setIdAttribute")
        public void setIdAttribute(String name,
                                                                             boolean isId)

        If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute.

        Parameters:
        name - The attribute name.
        isId - if set to true [is id].
      • setIdAttributeNS

        @DOMNameAttribute(name="setIdAttributeNS")
        public void setIdAttributeNS(String namespaceURI,
                                                                                 String localName,
                                                                                 boolean isId)

        If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute.

        Parameters:
        namespaceURI - The namespace URI.
        localName - Name of the local.
        isId - if set to true [is id].
      • setIdAttributeNode

        @DOMNameAttribute(name="setIdAttributeNode")
        public void setIdAttributeNode(Attr idAttr,
                                                                                     boolean isId)

        If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute.

        Parameters:
        idAttr - The id attr.
        isId - if set to true [is id].
      • getInnerHTML

        @DOMNameAttribute(name="innerHTML")
        public String getInnerHTML()

        Returns a fragment of HTML or XML that represents the element's contents. Can be set, to replace the contents of the element with nodes parsed from the given string.

        Throws:
        com.aspose.ms.System.NotImplementedException - Value: The inner HTML.
      • setInnerHTML

        @DOMNameAttribute(name="innerHTML")
        public void setInnerHTML(String value)

        Returns a fragment of HTML or XML that represents the element's contents. Can be set, to replace the contents of the element with nodes parsed from the given string.

        Throws:
        com.aspose.ms.System.NotImplementedException - Value: The inner HTML.
      • getOuterHTML

        @DOMNameAttribute(name="outerHTML")
        public String getOuterHTML()

        Returns a fragment of HTML or XML that represents the element and its contents. Can be set, to replace the element with nodes parsed from the given string.

        Throws:
        com.aspose.ms.System.NotImplementedException - Value: The outer HTML.
      • setOuterHTML

        @DOMNameAttribute(name="outerHTML")
        public void setOuterHTML(String value)

        Returns a fragment of HTML or XML that represents the element and its contents. Can be set, to replace the element with nodes parsed from the given string.

        Throws:
        com.aspose.ms.System.NotImplementedException - Value: The outer HTML.
      • equals

        public boolean equals(Tag other)
        Overrides:
        equals in class Object