Rest.XmlNode

Fields

Name

Type

Access

Description

attrs

{object: object}

r/w

a GLib.HashTable of string name to string values for the attributes of the element.

children

{object: object}

r/w

a GLib.HashTable of string name to Rest.XmlNode for the children of the element.

content

str

r/w

the textual content of the element

name

str

r/w

the name of the element

next

Rest.XmlNode

r/w

the sibling Rest.XmlNode with the same name

ref_count

int

r

Methods

add_attr (attribute, value)

add_child (tag)

find (tag)

get_attr (attr_name)

print_ ()

set_content (value)

Details

class Rest.XmlNode

The Rest.XmlNode contains a parsed XmlNode for easy consumption

add_attr(attribute, value)
Parameters:
  • attribute (str) – name of the attribute

  • value (str) – value to set attribute to

Adds attribute to the given node.

add_child(tag)
Parameters:

tag (str) – name of the child node

Returns:

the newly added Rest.XmlNode; the node object is owned by, and valid for the life time of, the #RestXmlCreator.

Return type:

Rest.XmlNode

Adds a new node to the given parent node; to create the top-level node, parent should be None.

find(tag)
Parameters:

tag (str) – the name of a node

Returns:

the first child node, or None if it doesn’t exist.

Return type:

Rest.XmlNode

Searches for the first child node of self named tag.

get_attr(attr_name)
Parameters:

attr_name (str) – the name of an attribute

Returns:

the attribute value. This string is owned by Rest.XmlNode and should not be freed.

Return type:

str

Get the value of the attribute named attr_name, or None if it doesn’t exist.

print_()
Returns:

xml string representing the node.

Return type:

str

Recursively outputs given node and it’s children.

set_content(value)
Parameters:

value (str) – the content

Sets content for the given node.