com.aspose.html.dom

Class Element

    • Field Detail

      • _Tag

        public com.aspose.html.Tag _Tag
    • Constructor Detail

      • Element

        public Element(com.aspose.html.dom.DOMName name,
                       Document doc)

        Initializes a new instance of the Element class.

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

      • getAttributes

        public NamedNodeMap getAttributes()

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

        Overrides:
        getAttributes in class Node
      • hasAttributes

        public boolean hasAttributes()

        Returns whether this node (if it is an element) has any attributes

        Overrides:
        hasAttributes in class Node
        Returns:
        boolean true if this node has any attributes, false otherwise.
      • getLocalName

        public java.lang.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 name of the local.
        Overrides:
        getLocalName in class Node
      • getPrefix

        @DOMNameAttribute(name="prefix")
         @DOMNullableAttribute
        public java.lang.String getPrefix()

        The namespace prefix of this node, or null if it is unspecified. When it is defined to be null, setting it has no effect

        Value: The namespace prefix of this node.
        Overrides:
        getPrefix in class Node
      • getNodeName

        public java.lang.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
      • getTagName

        @DOMNameAttribute(name="tagName")
        public java.lang.String getTagName()

        The name of the element.

        Value: The name of the element.
      • getId

        @DOMNameAttribute(name="id")
        public java.lang.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(java.lang.String value)

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

        Value: The identifier.
      • getClassName

        @DOMNameAttribute(name="className")
        public java.lang.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(java.lang.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.
      • getTextContent

        public java.lang.String getTextContent()

        This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty or null, replaced by a single Text node containing the string this attribute is set to.

        Value: The content of the text.
        Overrides:
        getTextContent in class Node
      • setTextContent

        public void setTextContent(java.lang.String value)

        This attribute returns the text content of this node and its descendants. When it is defined to be null, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty or null, replaced by a single Text node containing the string this attribute is set to.

        Value: The content of the text.
        Overrides:
        setTextContent in class Node
      • getAttribute

        @DOMNameAttribute(name="getAttribute")
         @DOMNullableAttribute
        public java.lang.String getAttribute(java.lang.String name)

        Retrieves an attribute value by name.

        Parameters:
        name - The name of the attribute to retrieve.
        Returns:
        Returns attribute value
      • getAttributeNS

        @DOMNameAttribute(name="getAttributeNS")
         @DOMNullableAttribute
        public java.lang.String getAttributeNS(java.lang.String namespaceURI,
                                                                                                               java.lang.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(java.lang.String name,
                                                                        java.lang.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(java.lang.String namespaceURI,
                                                                            java.lang.String qualifiedName,
                                                                            java.lang.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(java.lang.String name)

        Removes an attribute by name.

        Parameters:
        name - The attribute name.
      • removeAttributeNS

        @DOMNameAttribute(name="removeAttributeNS")
        public void removeAttributeNS(java.lang.String namespaceURI,
                                                                                  java.lang.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(java.lang.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(java.lang.String namespaceURI,
                                                                               java.lang.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(java.lang.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(java.lang.String namespaceURI,
                                                                                    java.lang.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(java.lang.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(java.lang.String namespaceURI,
                                                                                                      java.lang.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
      • querySelectorAll

        public NodeList querySelectorAll(java.lang.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(java.lang.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(java.lang.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(java.lang.String namespaceURI,
                                                                                java.lang.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 java.lang.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.

        Value: The inner HTML.
      • setInnerHTML

        @DOMNameAttribute(name="innerHTML")
        public void setInnerHTML(java.lang.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.

        Value: The inner HTML.
      • getOuterHTML

        @DOMNameAttribute(name="outerHTML")
        public java.lang.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.

        Value: The outer HTML.
      • setOuterHTML

        @DOMNameAttribute(name="outerHTML")
        public void setOuterHTML(java.lang.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.

        Value: The outer HTML.
      • attachShadow

        @DOMNameAttribute(name="attachShadow")
         @DOMInitDictParameterAttribute(name="mode",
                                       optional=false)
        public ShadowRoot attachShadow(int mode)

        Creates shadow root and attaches it to current element.

        Parameters:
        mode - Mode in which shadow root will be created.
        Returns:
        Created ShadowRoot.
        Throws:
        com.aspose.html.dom.Error - NotSupportedError: Element does not support shadow tree.
        com.aspose.html.dom.Error - InvalidStateError: Element already has shadow tree.
      • getShadowRoot

        @DOMNameAttribute(name="shadowRoot")
        public ShadowRoot getShadowRoot()

        Returns shadowRoot stored on this element or null if it's closed.

        Value: The shadowRoot.
      • getElementsByClassName

        @DOMNameAttribute(name="getElementsByClassName")
        public HTMLCollection getElementsByClassName(java.lang.String classNames)

        Returns a live NodeList object containing all the elements in the document that have all the classes specified in argument. http://www.w3.org/TR/dom/

        Parameters:
        classNames - The string string that contains an unordered set of unique space-separated tokens representing classes (class names)
        Returns:
        The Element.
      • getStyleContainer

        public com.aspose.html.dom.css.engine.CSSStyleContainer getStyleContainer()

        Gets the style container.

        Value: The style container.
      • getComputedStyle

        public com.aspose.html.dom.css.engine.CSSStyleDeclaration getComputedStyle()

        This method is used to get the computed style as it is defined in CSS2.

        Returns:
        The computed style
      • getComputedStyle

        public com.aspose.html.dom.css.engine.CSSStyleDeclaration getComputedStyle(java.lang.String pseudoElement)

        This method is used to get the computed style as it is defined in CSS2.

        Parameters:
        pseudoElement - The pseudo element.
        Returns:
        The computed style
      • setData

        public void setData(java.lang.String slotName,
                            java.lang.Object data)
      • getData

        public java.lang.Object getData(java.lang.String slotName)
      • equals

        public boolean equals(com.aspose.html.Tag other)
      • dispose

        protected void dispose(boolean disposing)

        Releases unmanaged and - optionally - managed resources.

        Overrides:
        dispose in class Node
        Parameters:
        disposing - true to release both managed and unmanaged resources; false to release only unmanaged resources.
      • getTag

        public com.aspose.html.Tag getTag()