pugixml.pugi.XMLAttribute

class pugixml.pugi.XMLAttribute

Bases: pybind11_object

A light-weight handle for manipulating attributes in the DOM tree.

Methods

__bool__(self)

Determine if this attribute is not empty.

__eq__(self, other)

Return self == other.

__ge__(self, other)

Return self >= other.

__gt__(self, other)

Return self > other.

__hash__(self)

Return the hash value (unique for handles to the same object).

__init__(*args, **kwargs)

Overloaded function.

__le__(self, other)

Return self <= other.

__lt__(self, other)

Return self < other.

__ne__(self, other)

Return self != other.

as_bool(self[, default])

Return the attribute value as a boolean.

as_double(self[, default])

Return the attribute value as a number [DBL_MIN, DBL_MAX].

as_float(self[, default])

Return the attribute value as a number [FLT_MIN, FLT_MAX].

as_int(self[, default])

Return the attribute value as a number [INT_MIN, INT_MAX].

as_llong(self[, default])

Return the attribute value as a number [LLONG_MIN, LLONG_MAX].

as_string(self[, default])

Return the attribute value.

as_uint(self[, default])

Return the attribute value as a number [0, UINT_MAX].

as_ullong(self[, default])

Return the attribute value as a number [0, ULLONG_MAX].

empty(self)

Determine if this attribute is empty.

hash_value(self)

Return the hash value (unique for handles to the same object).

internal_object(self)

Return the internal object.

name(self)

Return the attribute name.

next_attribute(self)

Return the next attribute in the list of attributes of the parent node.

previous_attribute(self)

Return the previous attribute in the list of attributes of the parent node.

set_name(*args, **kwargs)

Overloaded function.

set_value(*args, **kwargs)

Overloaded function.

value(self)

Return the attribute value.

Member Documentation

__bool__(self: pugixml.pugi.XMLAttribute) bool

Determine if this attribute is not empty.

Returns:

True if this attribute is not empty, False otherwise.

__eq__(self: pugixml.pugi.XMLAttribute, other: pugixml.pugi.XMLAttribute) bool

Return self == other.

Parameters:

other – The attribute to compare.

Returns:

True if the internal objects are the same, False otherwise.

__ge__(self: pugixml.pugi.XMLAttribute, other: pugixml.pugi.XMLAttribute) bool

Return self >= other.

Parameters:

other – The attribute to compare.

Returns:

True if the result of comparing the internal objects is true, False otherwise.

__gt__(self: pugixml.pugi.XMLAttribute, other: pugixml.pugi.XMLAttribute) bool

Return self > other.

Parameters:

other – The attribute to compare.

Returns:

True if the result of comparing the internal objects is true, False otherwise.

__hash__(self: pugixml.pugi.XMLAttribute) int

Return the hash value (unique for handles to the same object).

This is equivalent to hash_value().

Returns:

The hash value.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pugixml.pugi.XMLAttribute) -> None

    Initialize XMLAttribute as an empty attribute.

  2. __init__(self: pugixml.pugi.XMLAttribute, p: pugixml.pugi.XMLAttributeStruct) -> None

    Initialize XMLAttribute with the internal object.

Parameters:

p – The internal object of the attribute to shallow copy.

__le__(self: pugixml.pugi.XMLAttribute, other: pugixml.pugi.XMLAttribute) bool

Return self <= other.

Parameters:

other – The attribute to compare.

Returns:

True if the result of comparing the internal objects is true, False otherwise.

__lt__(self: pugixml.pugi.XMLAttribute, other: pugixml.pugi.XMLAttribute) bool

Return self < other.

Parameters:

other – The attribute to compare.

Returns:

True if the result of comparing the internal objects is true, False otherwise.

__ne__(self: pugixml.pugi.XMLAttribute, other: pugixml.pugi.XMLAttribute) bool

Return self != other.

Parameters:

other – The attribute to compare.

Returns:

True if the internal objects are not the same, False otherwise.

as_bool(self: pugixml.pugi.XMLAttribute, default: bool = False) bool

Return the attribute value as a boolean.

Parameters:

default – The default value to return if the conversion fails or the attribute is empty.

Returns:

The attribute value as a boolean (returns True if the first character is in ‘1tTyY’ set), or the default value if the conversion fails or the attribute is empty.

as_double(self: pugixml.pugi.XMLAttribute, default: SupportsFloat | SupportsIndex = 0) float

Return the attribute value as a number [DBL_MIN, DBL_MAX].

Parameters:

default – The default value to return if the conversion fails or the attribute is empty.

Returns:

The attribute value as a number, or the default value if the conversion fails or the attribute is empty.

as_float(self: pugixml.pugi.XMLAttribute, default: SupportsFloat | SupportsIndex = 0) float

Return the attribute value as a number [FLT_MIN, FLT_MAX].

Parameters:

default – The default value to return if the conversion fails or the attribute is empty.

Returns:

The attribute value as a number, or the default value if the conversion fails or the attribute is empty.

as_int(self: pugixml.pugi.XMLAttribute, default: SupportsInt | SupportsIndex = 0) int

Return the attribute value as a number [INT_MIN, INT_MAX].

Parameters:

default – The default value to return if the conversion fails or the attribute is empty.

Returns:

The attribute value as a number, or the default value if the conversion fails or the attribute is empty.

as_llong(self: pugixml.pugi.XMLAttribute, default: SupportsInt | SupportsIndex = 0) int

Return the attribute value as a number [LLONG_MIN, LLONG_MAX].

Parameters:

default – The default value to return if the conversion fails or the attribute is empty.

Returns:

The attribute value as a number, or the default value if the conversion fails or the attribute is empty.

as_string(self: pugixml.pugi.XMLAttribute, default: str = '') str

Return the attribute value.

Parameters:

default – The default value to return if the attribute is empty.

Returns:

The attribute value, or the default value if the attribute is empty.

as_uint(self: pugixml.pugi.XMLAttribute, default: SupportsInt | SupportsIndex = 0) int

Return the attribute value as a number [0, UINT_MAX].

Parameters:

default – The default value to return if the conversion fails or the attribute is empty.

Returns:

The attribute value as a number, or the default value if the conversion fails or the attribute is empty.

as_ullong(self: pugixml.pugi.XMLAttribute, default: SupportsInt | SupportsIndex = 0) int

Return the attribute value as a number [0, ULLONG_MAX].

Parameters:

default – The default value to return if the conversion fails or the attribute is empty.

Returns:

The attribute value as a number, or the default value if the conversion fails or the attribute is empty.

empty(self: pugixml.pugi.XMLAttribute) bool

Determine if this attribute is empty.

Returns:

True if this attribute is empty, False otherwise.

hash_value(self: pugixml.pugi.XMLAttribute) int

Return the hash value (unique for handles to the same object).

Returns:

The hash value.

internal_object(self: pugixml.pugi.XMLAttribute) pugixml.pugi.XMLAttributeStruct

Return the internal object.

Returns:

The internal object of this attribute.

name(self: pugixml.pugi.XMLAttribute) str

Return the attribute name.

Returns:

The attribute name, or an empty string if the attribute is empty.

next_attribute(self: pugixml.pugi.XMLAttribute) pugixml.pugi.XMLAttribute

Return the next attribute in the list of attributes of the parent node.

Returns:

The next sibling of this attribute, or empty attribute if nothing exists.

previous_attribute(self: pugixml.pugi.XMLAttribute) pugixml.pugi.XMLAttribute

Return the previous attribute in the list of attributes of the parent node.

Returns:

The previous sibling of this attribute, or empty attribute if nothing exists.

set_name(*args, **kwargs)

Overloaded function.

  1. set_name(self: pugixml.pugi.XMLAttribute, name: str) -> bool

    Set the attribute name.

  2. set_name(self: pugixml.pugi.XMLAttribute, name: str, size: typing.SupportsInt | typing.SupportsIndex) -> bool

    Set the attribute name with the specified length.

Parameters:
  • name – The attribute name to set.

  • size – The length of the attribute name.

Returns:

False if the attribute is empty or there is not enough memory.

set_value(*args, **kwargs)

Overloaded function.

  1. set_value(self: pugixml.pugi.XMLAttribute, value: str) -> bool

    Set the attribute value.

  2. set_value(self: pugixml.pugi.XMLAttribute, value: str, size: typing.SupportsInt | typing.SupportsIndex) -> bool

    Set the attribute value with the specified length.

  3. set_value(self: pugixml.pugi.XMLAttribute, value: bool) -> bool

    Set the attribute value as a boolean (true or false).

  4. set_value(self: pugixml.pugi.XMLAttribute, value: float) -> bool

    Set the attribute value as a number [DBL_MIN, DBL_MAX].

  5. set_value(self: pugixml.pugi.XMLAttribute, value: typing.SupportsFloat | typing.SupportsIndex, precision: typing.SupportsInt | typing.SupportsIndex) -> bool

    Set the attribute value as a number with the specified precision [DBL_MIN, DBL_MAX].

  6. set_value(self: pugixml.pugi.XMLAttribute, value: typing.SupportsInt | typing.SupportsIndex) -> bool

    Set the attribute value as a number [LLONG_MIN, LLONG_MAX].

  7. set_value(self: pugixml.pugi.XMLAttribute, value: typing.SupportsInt | typing.SupportsIndex) -> bool

    Set the attribute value as a number [0, ULLONG_MAX].

Parameters:
  • value – The attribute value to set.

  • size – The length of the attribute value as a string.

  • precision – The precision of the attribute value as a floating point number.

Returns:

False if the attribute is empty or there is not enough memory.

value(self: pugixml.pugi.XMLAttribute) str

Return the attribute value.

Returns:

The attribute value, or an empty string if the attribute is empty.

See also

as_string()