@DOMObjectAttribute @DOMNameAttribute(name="Element") public class Element extends Node implements IParentNode, IChildNode
The Element interface represents an element in an HTML or XML document.
Node.Flags
Modifier and Type | Field and Description |
---|---|
com.aspose.html.Tag |
_Tag |
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, flags, nodeDocument, NOTATION_NODE, parent, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
EventMap
PropertyChanged, PropertyChangedDelegate
Constructor and Description |
---|
Element(com.aspose.html.dom.DOMName name,
Document doc)
Initializes a new instance of the
Element class. |
Modifier and Type | Method and Description |
---|---|
ShadowRoot |
attachShadow(int mode)
Creates shadow root and attaches it to current element.
|
protected void |
dispose(boolean disposing)
Releases unmanaged and - optionally - managed resources.
|
boolean |
equals(com.aspose.html.Tag other) |
java.lang.String |
getAttribute(java.lang.String name)
Retrieves an attribute value by name.
|
Attr |
getAttributeNode(java.lang.String name)
Retrieves an attribute node by name.
|
Attr |
getAttributeNodeNS(java.lang.String namespaceURI,
java.lang.String localName)
Retrieves an Attr node by local name and namespace URI.
|
java.lang.String |
getAttributeNS(java.lang.String namespaceURI,
java.lang.String localName)
Retrieves an attribute value by local name and namespace URI.
|
NamedNodeMap |
getAttributes()
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
|
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.
|
HTMLCollection |
getChildren()
Returns the child elements of current element.
|
java.lang.String |
getClassName()
The class attribute of the element.
|
com.aspose.html.dom.css.engine.CSSStyleDeclaration |
getComputedStyle()
This method is used to get the computed style as it is defined in CSS2.
|
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.
|
java.lang.Object |
getData(java.lang.String slotName) |
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.
|
HTMLCollection |
getElementsByTagName(java.lang.String name)
Returns a NodeList of all descendant Elements with a given tag name, in document order.
|
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.
|
Element |
getFirstElementChild()
Returns the first child element node of this element. null if this element has no child elements.
|
java.lang.String |
getId()
The element's identifier.
|
java.lang.String |
getInnerHTML()
Returns a fragment of HTML or XML that represents the element's contents.
|
Element |
getLastElementChild()
Returns the last child element node of this element. null if this element has no child elements.
|
java.lang.String |
getLocalName()
Returns the local part of the qualified name of this node.
|
java.lang.String |
getNamespaceURI()
The namespace URI of this node, or null if it is unspecified.
|
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.
|
java.lang.String |
getNodeName()
The name of this node, depending on its type.
|
int |
getNodeType()
A code representing the type of the underlying object.
|
java.lang.String |
getOuterHTML()
Returns a fragment of HTML or XML that represents the element and its contents.
|
java.lang.String |
getPrefix()
The namespace prefix of this node, or null if it is unspecified.
|
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.
|
TypeInfo |
getSchemaTypeInfo()
The type information associated with this element.
|
ShadowRoot |
getShadowRoot()
Returns shadowRoot stored on this element or null if it's closed.
|
com.aspose.html.dom.css.engine.CSSStyleContainer |
getStyleContainer()
Gets the style container.
|
com.aspose.html.Tag |
getTag() |
java.lang.String |
getTagName()
The name of the element.
|
java.lang.String |
getTextContent()
This attribute returns the text content of this node and its descendants.
|
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.
|
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.
|
boolean |
hasAttributes()
Returns whether this node (if it is an element) has any attributes
|
Element |
querySelector(java.lang.String selector)
Returns the first Element in document, which match selector
|
NodeList |
querySelectorAll(java.lang.String selector)
Returns a NodeList of all the Elements in document, which match selector
|
void |
remove()
Removes this instance.
|
void |
removeAttribute(java.lang.String name)
Removes an attribute by name.
|
Attr |
removeAttributeNode(Attr oldAttr)
Removes the specified attribute node.
|
void |
removeAttributeNS(java.lang.String namespaceURI,
java.lang.String localName)
Removes an attribute by local name and namespace URI.
|
void |
setAttribute(java.lang.String name,
java.lang.String value)
Adds a new attribute.
|
Attr |
setAttributeNode(Attr newAttr)
Adds a new attribute node.
|
Attr |
setAttributeNodeNS(Attr newAttr)
Adds a new attribute.
|
void |
setAttributeNS(java.lang.String namespaceURI,
java.lang.String qualifiedName,
java.lang.String value)
Adds a new attribute.
|
void |
setClassName(java.lang.String value)
The class attribute of the element.
|
void |
setData(java.lang.String slotName,
java.lang.Object data) |
void |
setId(java.lang.String value)
The element's identifier.
|
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.
|
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.
|
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.
|
void |
setInnerHTML(java.lang.String value)
Returns a fragment of HTML or XML that represents the element's contents.
|
void |
setOuterHTML(java.lang.String value)
Returns a fragment of HTML or XML that represents the element and its contents.
|
void |
setTextContent(java.lang.String value)
This attribute returns the text content of this node and its descendants.
|
adoptNode, appendChild, cloneNode, deepClone, finalize, getBaseURI, getChildNodes, getChildNodesInternal, getFirstChild, getLastChild, getNextSibling, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPreviousSibling, getRegisteredObservers, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceAll, replaceChild, setLocalName, setNamespaceURI, setNodeValue, setParentNode, setPrefix, toString
addEventListener, addEventListener, addEventListener, addEventListener, dispatchEvent, dispose, removeEventListener, removeEventListener, removeEventListener
fireNotifyPropertyChanged, getCurrentValues, getRuntimesBinding, setCurrentValues, setField, setRuntimesBinding
public NamedNodeMap getAttributes()
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
getAttributes
in class Node
public boolean hasAttributes()
Returns whether this node (if it is an element) has any attributes
hasAttributes
in class Node
true
if this node has any attributes, false
otherwise.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.getLocalName
in class Node
@DOMNameAttribute(name="namespaceURI") @DOMNullableAttribute public java.lang.String getNamespaceURI()
The namespace URI of this node, or null if it is unspecified.
getNamespaceURI
in class Node
@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.public java.lang.String getNodeName()
The name of this node, depending on its type.
Value: The name of the node.getNodeName
in class Node
public int getNodeType()
A code representing the type of the underlying object.
Value: The code representing the type of the node.getNodeType
in class Node
@DOMNameAttribute(name="tagName") public java.lang.String getTagName()
The name of the element.
Value: The name of the element.@DOMNameAttribute(name="id") public java.lang.String getId()
The element's identifier. See the id attribute definition in HTML 4.01.
Value: The identifier.@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.@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.@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.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.getTextContent
in class Node
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.setTextContent
in class Node
@DOMNameAttribute(name="getAttribute") @DOMNullableAttribute public java.lang.String getAttribute(java.lang.String name)
Retrieves an attribute value by name.
name
- The name of the attribute to retrieve.@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.
namespaceURI
- The namespace URI.localName
- Name of the local.@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
name
- The attribute name.value
- The value.@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.
namespaceURI
- The namespace URI.qualifiedName
- Name of the qualified.value
- The value.@DOMNameAttribute(name="removeAttribute") public void removeAttribute(java.lang.String name)
Removes an attribute by name.
name
- The attribute name.@DOMNameAttribute(name="removeAttributeNS") public void removeAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
Removes an attribute by local name and namespace URI.
namespaceURI
- The namespace URI.localName
- Name of the local.@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.
name
- The attribute name.true
if the specified name has attribute; otherwise, false
.@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.
namespaceURI
- The namespace URI.localName
- Name of the local.true
if [has attribute NS] [the specified namespace URI]; otherwise, false
.@DOMNameAttribute(name="getAttributeNode") public Attr getAttributeNode(java.lang.String name)
Retrieves an attribute node by name.
name
- The attribute name.@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.
newAttr
- The new attr.@DOMNameAttribute(name="removeAttributeNode") public Attr removeAttributeNode(Attr oldAttr)
Removes the specified attribute node.
oldAttr
- The old attr.@DOMNameAttribute(name="getAttributeNodeNS") public Attr getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)
Retrieves an Attr node by local name and namespace URI.
namespaceURI
- The namespace URI.localName
- Name of the local.@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.
newAttr
- The new attr.@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.
name
- The tag name.@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.
namespaceURI
- The namespace URI.localName
- Name of the local.public void remove()
Removes this instance.
remove
in interface IChildNode
public Element getFirstElementChild()
Returns the first child element node of this element. null if this element has no child elements.
Value: The first element child.getFirstElementChild
in interface IParentNode
getFirstElementChild
in interface IElementTraversal
public Element getLastElementChild()
Returns the last child element node of this element. null if this element has no child elements.
Value: The last element child.getLastElementChild
in interface IParentNode
getLastElementChild
in interface IElementTraversal
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.
getPreviousElementSibling
in interface IElementTraversal
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.
getNextElementSibling
in interface IElementTraversal
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.getChildElementCount
in interface IParentNode
getChildElementCount
in interface IElementTraversal
public HTMLCollection getChildren()
Returns the child elements of current element.
Value: The children collectiongetChildren
in interface IParentNode
public NodeList querySelectorAll(java.lang.String selector)
Returns a NodeList of all the Elements in document, which match selector
querySelectorAll
in interface IParentNode
selector
- The selectorHTMLCollection
public Element querySelector(java.lang.String selector)
Returns the first Element in document, which match selector
querySelector
in interface IParentNode
selector
- The selector.@DOMNameAttribute(name="schemaTypeInfo") public TypeInfo getSchemaTypeInfo()
The type information associated with this element.
Value: The schema type information.@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.
name
- The attribute name.isId
- if set to true
[is id].@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.
namespaceURI
- The namespace URI.localName
- Name of the local.isId
- if set to true
[is id].@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.
idAttr
- The id attr.isId
- if set to true
[is id].@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.@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.@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.@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.@DOMNameAttribute(name="attachShadow") @DOMInitDictParameterAttribute(name="mode", optional=false) public ShadowRoot attachShadow(int mode)
Creates shadow root and attaches it to current element.
mode
- Mode in which shadow root will be created.ShadowRoot
.Error
- NotSupportedError: Element does not support shadow tree.Error
- InvalidStateError: Element already has shadow tree.@DOMNameAttribute(name="shadowRoot") public ShadowRoot getShadowRoot()
Returns shadowRoot stored on this element or null if it's closed.
Value: The shadowRoot.@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/
classNames
- The string string that contains an unordered set of unique space-separated tokens representing classes (class names)Element
.public com.aspose.html.dom.css.engine.CSSStyleContainer getStyleContainer()
Gets the style container.
Value: The style container.public com.aspose.html.dom.css.engine.CSSStyleDeclaration getComputedStyle()
This method is used to get the computed style as it is defined in CSS2.
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.
pseudoElement
- The pseudo element.public void setData(java.lang.String slotName, java.lang.Object data)
public java.lang.Object getData(java.lang.String slotName)
public boolean equals(com.aspose.html.Tag other)
protected void dispose(boolean disposing)
Releases unmanaged and - optionally - managed resources.
public com.aspose.html.Tag getTag()