Xmlb.Node

g GObject.Object GObject.Object Xmlb.Node Xmlb.Node GObject.Object->Xmlb.Node

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

export (flags)

get_attr (name)

get_attr_as_uint (name)

get_child ()

get_children ()

get_data (key)

get_depth ()

get_element ()

get_next ()

get_parent ()

get_root ()

get_silo ()

get_tail ()

get_text ()

get_text_as_uint ()

query (xpath, limit)

query_attr (xpath, name)

query_attr_as_uint (xpath, name)

query_export (xpath)

query_first (xpath)

query_first_full (query)

query_first_with_context (query, context)

query_full (query)

query_text (xpath)

query_text_as_uint (xpath)

query_with_context (query, context)

set_data (key, data)

transmogrify (func_text, func_tail, *user_data)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Xmlb.Node(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Xmlb.NodeClass

export(flags)
Parameters:

flags (Xmlb.NodeExportFlags) – some Xmlb.NodeExportFlags, e.g. Xmlb.NodeExportFlags.NONE

Raises:

GLib.Error

Returns:

XML data, or None for an error

Return type:

str

Exports the node back to XML.

New in version 0.1.0.

get_attr(name)
Parameters:

name (str) – an attribute name, e.g. “type”

Returns:

a string, or None for unset

Return type:

str

Gets some attribute text data for a specific node.

New in version 0.1.0.

get_attr_as_uint(name)
Parameters:

name (str) – an attribute name, e.g. type

Returns:

a guint64, or GObject.G_MAXUINT64 if unfound

Return type:

int

Gets some attribute text data for a specific node.

New in version 0.1.0.

get_child()
Returns:

a Xmlb.Node, or None

Return type:

Xmlb.Node

Gets the first child node for the current node.

New in version 0.1.0.

get_children()
Returns:

an array of children

Return type:

[Xmlb.Node]

Gets all the children for the current node.

New in version 0.1.0.

get_data(key)
Parameters:

key (str) – a string key, e.g. fwupd::RemoteId

Returns:

a GLib.Bytes, or None if not found

Return type:

GLib.Bytes

Gets any data that has been set on the node using Xmlb.Node.set_data().

This will only work across queries to the associated silo if the silo has its Xmlb.Silo :enable-node-cache property set to True. Otherwise a new Xmlb.Node may be constructed for future queries which return the same element as a result.

New in version 0.1.0.

get_depth()
Returns:

a integer, where 0 is the root node itself.

Return type:

int

Gets the depth of the node to a root.

New in version 0.1.0.

get_element()
Returns:

a string, or None for the root node

Return type:

str

Gets the element name for a specific node.

New in version 0.1.0.

get_next()
Returns:

a Xmlb.Node, or None

Return type:

Xmlb.Node

Gets the next sibling node for the current node.

New in version 0.1.0.

get_parent()
Returns:

a Xmlb.Node, or None

Return type:

Xmlb.Node

Gets the parent node for the current node.

New in version 0.1.0.

get_root()
Returns:

a Xmlb.Node, or None

Return type:

Xmlb.Node

Gets the root node for the node.

New in version 0.1.0.

get_silo()
Returns:

a Xmlb.Silo

Return type:

Xmlb.Silo

Gets the Xmlb.Silo for the node.

New in version 0.2.0.

get_tail()
Returns:

a string, or None for unset

Return type:

str

Gets the tail data for a specific node.

New in version 0.1.12.

get_text()
Returns:

a string, or None for unset

Return type:

str

Gets the text data for a specific node.

New in version 0.1.0.

get_text_as_uint()
Returns:

a guint64, or GObject.G_MAXUINT64 if unfound

Return type:

int

Gets some attribute text data for a specific node.

New in version 0.1.0.

query(xpath, limit)
Parameters:
  • xpath (str) – an XPath, e.g. id[abe.desktop]

  • limit (int) – maximum number of results to return, or 0 for “all”

Raises:

GLib.Error

Returns:

results, or None if unfound

Return type:

[Xmlb.Node]

Searches the silo using an XPath query, returning up to limit results.

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.1.0.

query_attr(xpath, name)
Parameters:
  • xpath (str) – An XPath, e.g. /components/component[@type=desktop]/id[abe.desktop]

  • name (str) – an attribute name, e.g. type

Raises:

GLib.Error

Returns:

a string, or None if unfound

Return type:

str

Searches the node using an XPath query, returning up to one result.

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.1.0.

query_attr_as_uint(xpath, name)
Parameters:
  • xpath (str) – An XPath, e.g. /components/component[@type=desktop]/id[abe.desktop]

  • name (str) – an attribute name, e.g. type

Raises:

GLib.Error

Returns:

a #guint64, or GObject.G_MAXUINT64 if unfound

Return type:

int

Searches the node using an XPath query, returning up to one result.

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.1.0.

query_export(xpath)
Parameters:

xpath (str) – An XPath, e.g. /components/component[@type=desktop]/id[abe.desktop]

Raises:

GLib.Error

Returns:

a string, or None if unfound

Return type:

str

Searches the node using an XPath query, returning an XML string of the result and any children.

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.1.0.

query_first(xpath)
Parameters:

xpath (str) – An XPath, e.g. /components/component[@type=desktop]/id[abe.desktop]

Raises:

GLib.Error

Returns:

a Xmlb.Node, or None if unfound

Return type:

Xmlb.Node

Searches the node using an XPath query, returning up to one result.

Please note: Only a tiny subset of XPath 1.0 is supported.

New in version 0.1.0.

query_first_full(query)
Parameters:

query (Xmlb.Query) – an Xmlb.Query

Raises:

GLib.Error

Returns:

a Xmlb.Node, or None if unfound

Return type:

Xmlb.Node

Searches the silo using a prepared query, returning up to one result. To search using a query with bound values, use Xmlb.Node.query_first_with_context().

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.1.11.

query_first_with_context(query, context)
Parameters:
Raises:

GLib.Error

Returns:

a Xmlb.Node, or None if unfound

Return type:

Xmlb.Node

Searches the silo using a prepared query, returning up to one result.

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.3.0.

query_full(query)
Parameters:

query (Xmlb.Query) – an Xmlb.Query

Raises:

GLib.Error

Returns:

results, or None if unfound

Return type:

[Xmlb.Node]

Searches the silo using a prepared query. To search using a query with bound values, use Xmlb.Node.query_with_context().

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.1.4.

query_text(xpath)
Parameters:

xpath (str) – An XPath, e.g. /components/component[@type=desktop]/id[abe.desktop]

Raises:

GLib.Error

Returns:

a string, or None if unfound

Return type:

str

Searches the node using an XPath query, returning up to one result.

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.1.0.

query_text_as_uint(xpath)
Parameters:

xpath (str) – An XPath, e.g. /components/component[@type=desktop]/id[abe.desktop]

Raises:

GLib.Error

Returns:

a #guint64, or GObject.G_MAXUINT64 if unfound

Return type:

int

Searches the node using an XPath query, returning up to one result.

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.1.0.

query_with_context(query, context)
Parameters:
Raises:

GLib.Error

Returns:

results, or None if unfound

Return type:

[Xmlb.Node]

Searches the silo using a prepared query, substituting values from the bindings in context for bound opcodes as needed.

It is safe to call this function from a different thread to the one that created the Xmlb.Silo.

Please note: Only a subset of XPath is supported.

New in version 0.3.0.

set_data(key, data)
Parameters:

Sets some data on the node which can be retrieved using Xmlb.Node.get_data().

This will only work across queries to the associated silo if the silo has its Xmlb.Silo :enable-node-cache property set to True. Otherwise a new Xmlb.Node may be constructed for future queries which return the same element as a result.

New in version 0.1.0.

transmogrify(func_text, func_tail, *user_data)
Parameters:
Returns:

True if all nodes were visited

Return type:

bool

Traverses a tree starting from self. It calls the given functions for each node visited. This allows transmogrification of the source, for instance converting the XML description to PangoMarkup or even something completely different like markdown.

The traversal can be halted at any point by returning True from func.

New in version 0.1.12.