| Top |
Functions for manipulating XML node trees and saving/loading to/from XML content in strings or files. XML node trees use the glib GNode N-ary tree data type for added flexibility.
GNode * ipatch_xml_new_node (GNode *parent,const char *name,const char *value,const char *attr_name,...);
Create a new XML tree node and append it to the given parent
, if supplied.
Note that the returned GNode can be used with other N-Array glib operations.
[skip]
parent |
Parent node to add new
node to as a child, or |
[nullable] |
name |
Name of the new XML node |
|
value |
Text value to assign to the new node or |
[nullable] |
attr_name |
First attribute name to assign or |
[nullable] |
... |
If |
[type char*] |
GNode * ipatch_xml_new_node_strv (GNode *parent,const char *name,const char *value,const char **attr_names,const char **attr_values);
Like ipatch_xml_new_node() but takes attribute name/values as separate strv
arrays.
[skip]
parent |
Parent node to add
new node to as a child, or |
[nullable] |
name |
Name of the new XML node |
|
value |
Text value to assign to the new node or |
[nullable] |
attr_names |
|
[array zero-terminated=1][nullable] |
attr_values |
|
[array zero-terminated=1][nullable] |
gpointer ipatch_xml_get_data (GNode *node,const char *key);
Lookup data assigned to an XML node.
[skip]
void ipatch_xml_set_data (GNode *node,const char *key,gpointer data);
Assigns arbitrary data to an XML node specified by a key
.
[skip]
void ipatch_xml_set_data_full (GNode *node,const char *key,gpointer data,GDestroyNotify destroy_func);
Assigns arbitrary data to an XML node specified by a key
. Also assigns a
destroy_func
callback to destroy the data when it is removed.
[skip]
gpointer ipatch_xml_steal_data (GNode *node,const char *key);
Remove keyed data from an XML node, but don't call the data's destroy notify. Caller is thus given the ownership of the data.
[skip]
gpointer ipatch_xml_get_qdata (GNode *node,GQuark quark);
Lookup data assigned to an XML node using a quark. This is faster than
ipatch_xml_get_data() since the key must be converted to a quark anyways.
[skip]
void ipatch_xml_set_qdata (GNode *node,GQuark quark,gpointer data);
Assigns arbitrary data to an XML node specified by a quark
key. This is
faster than ipatch_xml_set_data() since the key must be converted to a quark
anyways.
[skip]
void ipatch_xml_set_qdata_full (GNode *node,GQuark quark,gpointer data,GDestroyNotify destroy_func);
Assigns arbitrary data to an XML node specified by a key
. Also assigns a
destroy_func
callback to destroy the data when it is removed. This is
faster than ipatch_xml_set_data_full() since the key must be converted to a quark
anyways.
[skip]
gpointer ipatch_xml_steal_qdata (GNode *node,GQuark quark);
Remove keyed data from an XML node, but don't call the data's destroy notify.
Caller is thus given the ownership of the data. This is faster than
ipatch_xml_steal_data() since the key must be converted to a quark
anyways.
[skip]
void
ipatch_xml_destroy (GNode *node);
Free an XML tree (a root node
and all its children). Does not need to be
the actual root of a tree, i.e., can remove a sub tree.
[skip]
GNode *
ipatch_xml_copy (GNode *node);
Perform a deep copy on an XML tree.
[skip]
void ipatch_xml_set_name (GNode *node,const char *name);
Set the name of an XML node.
[skip]
void ipatch_xml_set_value (GNode *node,const char *value);
Set the text value of an XML node.
[skip]
void ipatch_xml_set_value_printf (GNode *node,const char *format,...);
Assign a value to an XML node using a printf format and arguments.
[skip]
void ipatch_xml_take_name (GNode *node,char *name);
Like ipatch_xml_set_name() but takes over the allocation of name
rather than
duplicating it.
[skip]
void ipatch_xml_take_value (GNode *node,char *value);
Like ipatch_xml_set_value() but takes over the allocation of value
rather than
duplicating it.
[skip]
const char *
ipatch_xml_get_name (GNode *node);
Get the name of an XML node.
[skip]
gboolean ipatch_xml_test_name (GNode *node,const char *cmpname);
Test if the node has the given name.
[skip]
const char *
ipatch_xml_get_value (GNode *node);
Get the text value of an XML node.
[skip]
char *
ipatch_xml_dup_value (GNode *node);
Duplicate the text value of an XML node. Like ipatch_xml_get_value() but
makes a copy of the value which the caller owns.
[skip]
gboolean ipatch_xml_test_value (GNode *node,const char *cmpvalue);
Test if the node has the given value.
[skip]
void ipatch_xml_set_attribute (GNode *node,const char *attr_name,const char *attr_value);
Set or unset an attribute of an XML node. If there is already an existing
attribute with the given attr_name
, its value will be replaced.
[skip]
void ipatch_xml_set_attributes (GNode *node,const char *attr_name,const char *attr_value,const char *attr2_name,...);
Set one or more attributes of an XML node.
[skip]
const char * ipatch_xml_get_attribute (GNode *node,const char *attr_name);
Get the value of an attribute of an XML node.
[skip]
gboolean ipatch_xml_test_attribute (GNode *node,const char *attr_name,const char *cmpval);
Test if an attribute of an XML node is a given value or exists (cmpval
= NULL).
[skip]
GNode * ipatch_xml_find_child (GNode *node,const char *name);
Find a child node with the given name
. Only searches the children of node
and does not search recursively.
[skip]
GNode * ipatch_xml_find_by_path (GNode *node,const char *path);
Get a node in a tree from a path string.
[skip]
char * ipatch_xml_to_str (GNode *node,guint indent);
Render an XML tree to a string.
[skip]
gboolean ipatch_xml_save_to_file (GNode *node,guint indent,const char *filename,GError **err);
Store an XML tree to a file.
[skip]
GNode * ipatch_xml_from_str (const char *str,GError **err);
Parse XML content into an XML node tree.
[skip]
Newly allocated XML node tree or
NULL on error (err
may be set), can be freed with ipatch_xml_destroy().
GNode * ipatch_xml_load_from_file (const char *filename,GError **err);
Parse an XML file into an XML node tree.
[skip]
filename |
File name containing XML content to parse |
|
err |
Location to store error info or |
Newly allocated XML node tree
or NULL on error (err
may be set), can be freed with ipatch_xml_destroy().
IpatchXmlNode *
ipatch_xml_node_new (void);
Create a new XML node structure. Not normally used.
[skip]
void
ipatch_xml_node_free (IpatchXmlNode *xmlnode);
Free an XML node structure and its contents. Not normally used.
[skip]
IpatchXmlNode *
ipatch_xml_node_duplicate (const IpatchXmlNode *xmlnode);
Duplicate an XML node structure and its contents. Not normally used. Note that arbitrary user data assigned to the XML node will not be duplicated.
[skip]
IpatchXmlAttr *
ipatch_xml_attr_new (void);
Create a new XML attribute structure. Not normally used.
[skip]
void
ipatch_xml_attr_free (IpatchXmlAttr *attr);
Free an XML attribute structure. Not normally used.
[skip]
IpatchXmlAttr *
ipatch_xml_attr_duplicate (const IpatchXmlAttr *attr);
Duplicate an XML attribute structure. Not normally used.
[skip]
struct IpatchXmlAttr {
char *name;
char *value;
};
Structure for storing an XML attribute.
struct IpatchXmlNode {
char *name; /* XML element name */
char *value; /* Text content of element */
GData *qdata; /* To associate arbitrary data with XML nodes */
GList *attributes; /* List of IpatchXmlAttr structures */
};
An XML element node. Note that a given node can contain only one text value.