pidgin 2.14.14dev
Loading...
Searching...
No Matches
xmlnode.h File Reference

XML DOM functions. More...

#include <glib.h>
Include dependency graph for xmlnode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _xmlnode
 

Typedefs

typedef enum _XMLNodeType XMLNodeType
 The valid types for an xmlnode.
 
typedef struct _xmlnode xmlnode
 An xmlnode.
 

Enumerations

enum  _XMLNodeType { XMLNODE_TYPE_TAG , XMLNODE_TYPE_ATTRIB , XMLNODE_TYPE_DATA }
 The valid types for an xmlnode. More...
 

Functions

xmlnodexmlnode_new (const char *name)
 Creates a new xmlnode.
 
xmlnodexmlnode_new_child (xmlnode *parent, const char *name)
 Creates a new xmlnode child.
 
void xmlnode_insert_child (xmlnode *parent, xmlnode *child)
 Inserts a node into a node as a child.
 
xmlnodexmlnode_get_child (const xmlnode *parent, const char *name)
 Gets a child node named name.
 
xmlnodexmlnode_get_child_with_namespace (const xmlnode *parent, const char *name, const char *xmlns)
 Gets a child node named name in a namespace.
 
xmlnodexmlnode_get_next_twin (xmlnode *node)
 Gets the next node with the same name as node.
 
void xmlnode_insert_data (xmlnode *node, const char *data, gssize size)
 Inserts data into a node.
 
char * xmlnode_get_data (const xmlnode *node)
 Gets (escaped) data from a node.
 
char * xmlnode_get_data_unescaped (const xmlnode *node)
 Gets unescaped data from a node.
 
void xmlnode_set_attrib (xmlnode *node, const char *attr, const char *value)
 Sets an attribute for a node.
 
void xmlnode_set_attrib_with_prefix (xmlnode *node, const char *attr, const char *prefix, const char *value)
 Sets a prefixed attribute for a node.
 
void xmlnode_set_attrib_with_namespace (xmlnode *node, const char *attr, const char *xmlns, const char *value)
 Sets a namespaced attribute for a node.
 
void xmlnode_set_attrib_full (xmlnode *node, const char *attr, const char *xmlns, const char *prefix, const char *value)
 Sets a namespaced attribute for a node.
 
const char * xmlnode_get_attrib (const xmlnode *node, const char *attr)
 Gets an attribute from a node.
 
const char * xmlnode_get_attrib_with_namespace (const xmlnode *node, const char *attr, const char *xmlns)
 Gets a namespaced attribute from a node.
 
void xmlnode_remove_attrib (xmlnode *node, const char *attr)
 Removes an attribute from a node.
 
void xmlnode_remove_attrib_with_namespace (xmlnode *node, const char *attr, const char *xmlns)
 Removes a namespaced attribute from a node.
 
void xmlnode_set_namespace (xmlnode *node, const char *xmlns)
 Sets the namespace of a node.
 
const char * xmlnode_get_namespace (xmlnode *node)
 Returns the namespace of a node.
 
void xmlnode_set_prefix (xmlnode *node, const char *prefix)
 Sets the prefix of a node.
 
const char * xmlnode_get_prefix (const xmlnode *node)
 Returns the prefix of a node.
 
xmlnodexmlnode_get_parent (const xmlnode *child)
 Gets the parent node.
 
char * xmlnode_to_str (const xmlnode *node, int *len)
 Returns the node in a string of xml.
 
char * xmlnode_to_formatted_str (const xmlnode *node, int *len)
 Returns the node in a string of human readable xml.
 
xmlnodexmlnode_from_str (const char *str, gssize size)
 Creates a node from a string of XML.
 
xmlnodexmlnode_copy (const xmlnode *src)
 Creates a new node from the source node.
 
void xmlnode_free (xmlnode *node)
 Frees a node and all of its children.
 
xmlnodexmlnode_from_file (const char *dir, const char *filename, const char *description, const char *process)
 Creates a node from a XML File.
 

Detailed Description

XML DOM functions.

Definition in file xmlnode.h.

Typedef Documentation

◆ xmlnode

typedef struct _xmlnode xmlnode

An xmlnode.

Definition at line 48 of file xmlnode.h.

Enumeration Type Documentation

◆ _XMLNodeType

The valid types for an xmlnode.

Enumerator
XMLNODE_TYPE_TAG 

Just a tag.

XMLNODE_TYPE_ATTRIB 

Has attributes.

XMLNODE_TYPE_DATA 

Has data.

Definition at line 38 of file xmlnode.h.

Function Documentation

◆ xmlnode_copy()

xmlnode * xmlnode_copy ( const xmlnode src)

Creates a new node from the source node.

Parameters
srcThe node to copy.
Returns
A new copy of the src node.

◆ xmlnode_free()

void xmlnode_free ( xmlnode node)

Frees a node and all of its children.

Parameters
nodeThe node to free.

◆ xmlnode_from_file()

xmlnode * xmlnode_from_file ( const char *  dir,
const char *  filename,
const char *  description,
const char *  process 
)

Creates a node from a XML File.

Calling this on the root node of an XML document will parse the entire document into a tree of nodes, and return the xmlnode of the root.

Parameters
dirThe directory where the file is located
filenameThe filename
descriptionA description of the file being parsed. Displayed to the user if the file cannot be read.
processThe subsystem that is calling xmlnode_from_file. Used as the category for debugging.
Returns
The new node or NULL if an error occurred.
Since
2.6.0

◆ xmlnode_from_str()

xmlnode * xmlnode_from_str ( const char *  str,
gssize  size 
)

Creates a node from a string of XML.

Calling this on the root node of an XML document will parse the entire document into a tree of nodes, and return the xmlnode of the root.

Parameters
strThe string of xml.
sizeThe size of the string, or -1 if str is NUL-terminated.
Returns
The new node.

◆ xmlnode_get_attrib()

const char * xmlnode_get_attrib ( const xmlnode node,
const char *  attr 
)

Gets an attribute from a node.

Parameters
nodeThe node to get an attribute from.
attrThe attribute to get.
Returns
The value of the attribute.

◆ xmlnode_get_attrib_with_namespace()

const char * xmlnode_get_attrib_with_namespace ( const xmlnode node,
const char *  attr,
const char *  xmlns 
)

Gets a namespaced attribute from a node.

Parameters
nodeThe node to get an attribute from.
attrThe attribute to get
xmlnsThe namespace of the attribute to get
Returns
The value of the attribute/

◆ xmlnode_get_child()

xmlnode * xmlnode_get_child ( const xmlnode parent,
const char *  name 
)

Gets a child node named name.

Parameters
parentThe parent node.
nameThe child's name.
Returns
The child or NULL.

◆ xmlnode_get_child_with_namespace()

xmlnode * xmlnode_get_child_with_namespace ( const xmlnode parent,
const char *  name,
const char *  xmlns 
)

Gets a child node named name in a namespace.

Parameters
parentThe parent node.
nameThe child's name.
xmlnsThe namespace.
Returns
The child or NULL.

◆ xmlnode_get_data()

char * xmlnode_get_data ( const xmlnode node)

Gets (escaped) data from a node.

Parameters
nodeThe node to get data from.
Returns
The data from the node or NULL. This data is in raw escaped format. You must g_free this string when finished using it.

◆ xmlnode_get_data_unescaped()

char * xmlnode_get_data_unescaped ( const xmlnode node)

Gets unescaped data from a node.

Parameters
nodeThe node to get data from.
Returns
The data from the node, in unescaped form. You must g_free this string when finished using it.

◆ xmlnode_get_namespace()

const char * xmlnode_get_namespace ( xmlnode node)

Returns the namespace of a node.

Parameters
nodeThe node to get the namepsace from
Returns
The namespace of this node

◆ xmlnode_get_next_twin()

xmlnode * xmlnode_get_next_twin ( xmlnode node)

Gets the next node with the same name as node.

Parameters
nodeThe node of a twin to find.
Returns
The twin of node or NULL.

◆ xmlnode_get_parent()

xmlnode * xmlnode_get_parent ( const xmlnode child)

Gets the parent node.

Parameters
childThe child node.
Returns
The parent or NULL.
Since
2.6.0

◆ xmlnode_get_prefix()

const char * xmlnode_get_prefix ( const xmlnode node)

Returns the prefix of a node.

Parameters
nodeThe node to get the prefix from
Returns
The prefix of this node

◆ xmlnode_insert_child()

void xmlnode_insert_child ( xmlnode parent,
xmlnode child 
)

Inserts a node into a node as a child.

Parameters
parentThe parent node to insert child into.
childThe child node to insert into parent.

◆ xmlnode_insert_data()

void xmlnode_insert_data ( xmlnode node,
const char *  data,
gssize  size 
)

Inserts data into a node.

Parameters
nodeThe node to insert data into.
dataThe data to insert.
sizeThe size of the data to insert. If data is null-terminated you can pass in -1.

◆ xmlnode_new()

xmlnode * xmlnode_new ( const char *  name)

Creates a new xmlnode.

Parameters
nameThe name of the node.
Returns
The new node.

◆ xmlnode_new_child()

xmlnode * xmlnode_new_child ( xmlnode parent,
const char *  name 
)

Creates a new xmlnode child.

Parameters
parentThe parent node.
nameThe name of the child node.
Returns
The new child node.

◆ xmlnode_remove_attrib()

void xmlnode_remove_attrib ( xmlnode node,
const char *  attr 
)

Removes an attribute from a node.

Parameters
nodeThe node to remove an attribute from.
attrThe attribute to remove.

◆ xmlnode_remove_attrib_with_namespace()

void xmlnode_remove_attrib_with_namespace ( xmlnode node,
const char *  attr,
const char *  xmlns 
)

Removes a namespaced attribute from a node.

Parameters
nodeThe node to remove an attribute from
attrThe attribute to remove
xmlnsThe namespace of the attribute to remove

◆ xmlnode_set_attrib()

void xmlnode_set_attrib ( xmlnode node,
const char *  attr,
const char *  value 
)

Sets an attribute for a node.

Parameters
nodeThe node to set an attribute for.
attrThe name of the attribute.
valueThe value of the attribute.

◆ xmlnode_set_attrib_full()

void xmlnode_set_attrib_full ( xmlnode node,
const char *  attr,
const char *  xmlns,
const char *  prefix,
const char *  value 
)

Sets a namespaced attribute for a node.

Parameters
nodeThe node to set an attribute for.
attrThe name of the attribute to set
xmlnsThe namespace of the attribute to ste
prefixThe prefix of the attribute to ste
valueThe value of the attribute
Since
2.6.0

◆ xmlnode_set_attrib_with_namespace()

void xmlnode_set_attrib_with_namespace ( xmlnode node,
const char *  attr,
const char *  xmlns,
const char *  value 
)

Sets a namespaced attribute for a node.

Parameters
nodeThe node to set an attribute for.
attrThe name of the attribute to set
xmlnsThe namespace of the attribute to ste
valueThe value of the attribute
Deprecated:
Use xmlnode_set_attrib_full instead.

◆ xmlnode_set_attrib_with_prefix()

void xmlnode_set_attrib_with_prefix ( xmlnode node,
const char *  attr,
const char *  prefix,
const char *  value 
)

Sets a prefixed attribute for a node.

Parameters
nodeThe node to set an attribute for.
attrThe name of the attribute to set
prefixThe prefix of the attribute to ste
valueThe value of the attribute
Deprecated:
Use xmlnode_set_attrib_full instead.

◆ xmlnode_set_namespace()

void xmlnode_set_namespace ( xmlnode node,
const char *  xmlns 
)

Sets the namespace of a node.

Parameters
nodeThe node to qualify
xmlnsThe namespace of the node

◆ xmlnode_set_prefix()

void xmlnode_set_prefix ( xmlnode node,
const char *  prefix 
)

Sets the prefix of a node.

Parameters
nodeThe node to qualify
prefixThe prefix of the node

◆ xmlnode_to_formatted_str()

char * xmlnode_to_formatted_str ( const xmlnode node,
int *  len 
)

Returns the node in a string of human readable xml.

Parameters
nodeThe starting node to output.
lenAddress for the size of the string.
Returns
The node as human readable string including tab and new line characters. You must g_free this string when finished using it.

◆ xmlnode_to_str()

char * xmlnode_to_str ( const xmlnode node,
int *  len 
)

Returns the node in a string of xml.

Parameters
nodeThe starting node to output.
lenAddress for the size of the string.
Returns
The node represented as a string. You must g_free this string when finished using it.