pugixml.pugi.XPathNodeSet

class pugixml.pugi.XPathNodeSet

Bases: pybind11_object

A fixed-size collection of XPath nodes.

Attributes

TYPE_UNSORTED = 0

Not ordered.

TYPE_SORTED = 1

Sorted by document order (ascending).

TYPE_SORTED_REVERSE = 2

Sorted by document order (descending).

Methods

Type

Collection type.

__getitem__(*args, **kwargs)

Overloaded function.

__init__(*args, **kwargs)

Overloaded function.

__iter__(self)

Return an iterator for this collection of XPath nodes.

__len__(self)

Return the collection size.

empty(self)

Determine if this collection is empty.

first(self)

Return the first node in the collection by document order.

size(self)

Return the collection size.

sort(self[, reverse])

Sort the collection in ascending/descending order by document order.

type(self)

Return the collection type.

Member Documentation

class Type

Bases: IntEnum

Collection type.

Attributes

TYPE_UNSORTED = 0

Not ordered.

TYPE_SORTED = 1

Sorted by document order (ascending).

TYPE_SORTED_REVERSE = 2

Sorted by document order (descending).

__getitem__(*args, **kwargs)

Overloaded function.

  1. __getitem__(self: pugixml.pugi.XPathNodeSet, index: typing.SupportsInt | typing.SupportsIndex) -> pugixml.pugi.XPathNode

    Return the XPath node at the specified index from the collection.

  2. __getitem__(self: pugixml.pugi.XPathNodeSet, slice: slice) -> list[pugixml.pugi.XPathNode]

    Return a list of XPath nodes at the specified slice from the collection.

Parameters:
  • index – An index to specify position.

  • slice – A slice object to specify range.

Returns:

The XPath node(s) at the specified index/slice from the collection.

__init__(*args, **kwargs)

Overloaded function.

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

    Initialize XPathNodeSet as an empty collection.

  2. __init__(self: pugixml.pugi.XPathNodeSet, other: pugixml.pugi.XPathNodeSet) -> None

    Initialize XPathNodeSet with a copy of the collection.

Parameters:

other – The collection to copy.

__iter__(self: pugixml.pugi.XPathNodeSet) Iterator[XPathNode]

Return an iterator for this collection of XPath nodes.

Returns:

The iterator for the collection of XPath nodes.

__len__(self: pugixml.pugi.XPathNodeSet) int

Return the collection size.

This is equivalent to size().

Returns:

The collection size.

empty(self: pugixml.pugi.XPathNodeSet) bool

Determine if this collection is empty.

Returns:

True if the collection is empty, False otherwise.

first(self: pugixml.pugi.XPathNodeSet) pugixml.pugi.XPathNode

Return the first node in the collection by document order.

Returns:

The first node in the collection, or empty node if the collection is empty.

size(self: pugixml.pugi.XPathNodeSet) int

Return the collection size.

Returns:

The collection size.

sort(self: pugixml.pugi.XPathNodeSet, reverse: bool = False) None

Sort the collection in ascending/descending order by document order.

Parameters:

reverse – If True, sort in descending order.

type(self: pugixml.pugi.XPathNodeSet) pugixml.pugi.XPathNodeSet.Type

Return the collection type.

Returns:

The collection type.