Attr

Overview

Attr is a class in Aspose.Html FOSS for Python. Inherits from: Node.

An attribute attached to an Element.

This class provides 23 methods for working with Attr objects in Python programs. Available methods include: __init__, add_event_listener, append_child, clone_node, compare_document_position, contains, dispatch_event, get_feature, get_root_node, get_user_data, has_child_nodes, insert_before, and 11 additional methods. All public members are accessible to any Python application after installing the Aspose.Html FOSS for Python package. Properties: child_nodes, first_child, is_connected, last_child, local_name, name, and 14 more.

Properties

NameTypeAccessDescription
node_namestrReadThe attribute name.
node_valuestrRead/WriteThe attribute value string.
namestrReadThe attribute name.
valuestrRead/WriteThe attribute value.
owner_elementElement | NoneReadThe Element this Attr is attached to, or None.
namespace_uristr | NoneReadThe namespace URI of this attribute, or None for no namespace.
prefixstr | NoneReadThe namespace prefix of this attribute, or None if no prefix.
specifiedboolReadAlways True — DOM3 legacy attribute.
local_namestrReadThe local part of the attribute name.
node_typeintReadInteger node type constant from NodeType.
text_contentstr | NoneRead/WriteThe text content of this node, or None for Document and DocumentType.
parent_nodeNode | NoneReadThe parent node, or None if this node has no parent.
parent_elementElement | NoneReadThe parent node if it is an Element; None otherwise.
is_connectedboolReadWhether this node is part of a document’s node tree (WHATWG DOM §4.4).
owner_documentDocument | NoneReadThe Document this node belongs to, or None for Document itself.
child_nodesNodeListReadA live NodeList of all child nodes.
first_childNode | NoneReadThe first child node, or None.
last_childNode | NoneReadThe last child node, or None.
previous_siblingNode | NoneReadThe preceding sibling node, or None.
next_siblingNode | NoneReadThe following sibling node, or None.

Methods

SignatureDescription
__init__(name: str, value: str, owner_element: Element | None, owner_document: Document | None, namespace_uri: str | None, local_name_ns: str | None)Calls init(name, value, owner_element, owner_document, namespace_uri, local_name_ns) on this Attr instance.
get_root_node(composed: bool)"Node"Return the root of the node’s tree.
has_child_nodes()boolReturn whether this node has at least one direct child node.
lookup_namespace_uri(prefix: str | None)str | NoneReturn the effective namespace URI for prefix in this node context.
lookup_prefix(namespace_uri: str | None)str | NoneReturn the effective prefix for namespace_uri in this node context.
is_default_namespace(namespace_uri: str | None)boolReturn whether namespace_uri equals this node context default namespace.
is_supported(feature: str, version: str | None)boolReturn legacy feature-probe compatibility status.
get_feature(feature: str, version: str | None)object | NoneReturn the legacy feature object for a probe, or None.
set_user_data(key: str, data: object | None, handler: object | None)object | NoneStore or clear node-local user data and return the previous value.
get_user_data(key: str)object | NoneReturn node-local user data for key or None when absent.
append_child(node: Node)NodeAppend node as the last child of this node.
insert_before(node: Node, reference: Node | None)NodeInsert node before reference in the child list.
remove_child(node: Node)NodeRemove node from the child list and return it.
replace_child(new_child: Node, old_child: Node)NodeReplace old_child with new_child.
clone_node(deep: bool)NodeReturn a copy of this node.
normalize()Put this node and its entire subtree into normalized form.
contains(other: Node | None)boolReturn True if other is an inclusive descendant of this node.
compare_document_position(other: "Node")intReturn a bitmask describing the position of other relative to this node.
is_equal_node(other: Node | None)boolReturn True if other has the same structure as this node.
is_same_node(other_node: Node | None)boolReturn True when other_node is this node instance.
add_event_listener(type: str, listener: Callable, capture: bool, once: bool)Register listener for events of type.
remove_event_listener(type: str, listener: Callable, capture: bool)Deregister a previously-registered listener.
dispatch_event(event: "Event")boolDispatch event through the ancestor tree.

See Also