Xmlb.Node¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Xmlb.Node(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- export(flags)¶
- Parameters:
flags (
Xmlb.NodeExportFlags
) – someXmlb.NodeExportFlags
, e.g.Xmlb.NodeExportFlags.NONE
- Raises:
- Returns:
XML data, or
None
for an error- Return type:
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:
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:
Gets some attribute text data for a specific node.
New in version 0.1.0.
- get_child()¶
-
Gets the first child node for the current node.
New in version 0.1.0.
- get_children()¶
- Returns:
an array of children
- Return type:
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
, orNone
if not found- Return type:
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 toTrue
. Otherwise a newXmlb.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:
Gets the depth of the node to a root.
New in version 0.1.0.
- get_element()¶
-
Gets the element name for a specific node.
New in version 0.1.0.
- get_next()¶
-
Gets the next sibling node for the current node.
New in version 0.1.0.
- get_parent()¶
-
Gets the parent node for the current node.
New in version 0.1.0.
- get_root()¶
-
Gets the root node for the node.
New in version 0.1.0.
- get_tail()¶
-
Gets the tail data for a specific node.
New in version 0.1.12.
- get_text()¶
-
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:
Gets some attribute text data for a specific node.
New in version 0.1.0.
- query(xpath, limit)¶
- Parameters:
- Raises:
- Returns:
results, or
None
if unfound- Return type:
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:
- Raises:
- Returns:
a string, or
None
if unfound- Return type:
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:
- Raises:
- Returns:
a #guint64, or
GObject.G_MAXUINT64
if unfound- Return type:
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:
- Returns:
a string, or
None
if unfound- Return type:
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:
- Returns:
- Return type:
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
) – anXmlb.Query
- Raises:
- Returns:
- Return type:
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:
query (
Xmlb.Query
) – anXmlb.Query
context (
Xmlb.QueryContext
orNone
) – context including values bound to opcodes of typeXmlb.OpcodeKind.BOUND_INTEGER
orXmlb.OpcodeKind.BOUND_TEXT
, orNone
if the query doesn’t need any context
- Raises:
- Returns:
- Return type:
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
) – anXmlb.Query
- Raises:
- Returns:
results, or
None
if unfound- Return type:
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:
- Returns:
a string, or
None
if unfound- Return type:
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:
- Returns:
a #guint64, or
GObject.G_MAXUINT64
if unfound- Return type:
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:
query (
Xmlb.Query
) – anXmlb.Query
context (
Xmlb.QueryContext
orNone
) – context including values bound to opcodes of typeXmlb.OpcodeKind.BOUND_INTEGER
orXmlb.OpcodeKind.BOUND_TEXT
, orNone
if the query doesn’t need any context
- Raises:
- Returns:
results, or
None
if unfound- Return type:
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:
key (
str
) – a string key, e.g.fwupd::RemoteId
data (
GLib.Bytes
) – aGLib.Bytes
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 toTrue
. Otherwise a newXmlb.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:
func_text (
Xmlb.NodeTransmogrifyFunc
) – (allow-none): aXmlb.BuilderNodeTraverseFunc
func_tail (
Xmlb.NodeTransmogrifyFunc
) – (allow-none): aXmlb.BuilderNodeTraverseFunc
user_data (
object
orNone
) – user pointer to pass to func, orNone
- Returns:
True
if all nodes were visited- Return type:
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.