xmlnode.h File Reference

XML DOM functions. More...

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 _xmlnode xmlnode
 An xmlnode.
typedef enum _XMLNodeType XMLNodeType
 The valid types for an xmlnode.

Enumerations

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

Functions

xmlnodexmlnode_copy (const xmlnode *src)
 Creates a new node from the source node.
void xmlnode_free (xmlnode *node)
 Frees a node and all of it's children.
xmlnodexmlnode_from_str (const char *str, gssize size)
 Creates a node from a string of XML.
const char * xmlnode_get_attrib (xmlnode *node, const char *attr)
 Gets an attribute from a node.
const char * xmlnode_get_attrib_with_namespace (xmlnode *node, const char *attr, const char *xmlns)
 Gets a namespaced attribute from a node.
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.
char * xmlnode_get_data (xmlnode *node)
 Gets data from a node.
const char * xmlnode_get_namespace (xmlnode *node)
 Returns the namespace of a node.
xmlnodexmlnode_get_next_twin (xmlnode *node)
 Gets the next node with the same name as node.
void xmlnode_insert_child (xmlnode *parent, xmlnode *child)
 Inserts a node into a node as a child.
void xmlnode_insert_data (xmlnode *node, const char *data, gssize size)
 Inserts data into a node.
xmlnodexmlnode_new (const char *name)
 Creates a new xmlnode.
xmlnodexmlnode_new_child (xmlnode *parent, const char *name)
 Creates a new xmlnode child.
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_attrib (xmlnode *node, const char *attr, const char *value)
 Sets an 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_namespace (xmlnode *node, const char *xmlns)
 Sets the namespace of a node.
char * xmlnode_to_formatted_str (xmlnode *node, int *len)
 Returns the node in a string of human readable xml.
char * xmlnode_to_str (xmlnode *node, int *len)
 Returns the node in a string of xml.


Detailed Description

XML DOM functions.

purple

Purple is the legal property of its developers, whose names are too numerous to list here. Please refer to the COPYRIGHT file distributed with this source distribution.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Definition in file xmlnode.h.


Enumeration Type Documentation

enum _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 35 of file xmlnode.h.


Function Documentation

xmlnode* xmlnode_copy ( const xmlnode src  ) 

Creates a new node from the source node.

Parameters:
src The node to copy.
Returns:
A new copy of the src node.

void xmlnode_free ( xmlnode node  ) 

Frees a node and all of it's children.

Parameters:
node The node to free.

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:
str The string of xml.
size The size of the string, or -1 if str is NUL-terminated.
Returns:
The new node.

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

Gets an attribute from a node.

Parameters:
node The node to get an attribute from.
attr The attribute to get.
Returns:
The value of the attribute.

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

Gets a namespaced attribute from a node.

Parameters:
node The node to get an attribute from.
attr The attribute to get
xmlns The namespace of the attribute to get
Returns:
The value of the attribute/

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

Gets a child node named name.

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

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:
parent The parent node.
name The child's name.
xmlns The namespace.
Returns:
The child or NULL.

char* xmlnode_get_data ( xmlnode node  ) 

Gets data from a node.

Parameters:
node The node to get data from.
Returns:
The data from the node. You must g_free this string when finished using it.

const char* xmlnode_get_namespace ( xmlnode node  ) 

Returns the namespace of a node.

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

xmlnode* xmlnode_get_next_twin ( xmlnode node  ) 

Gets the next node with the same name as node.

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

void xmlnode_insert_child ( xmlnode parent,
xmlnode child 
)

Inserts a node into a node as a child.

Parameters:
parent The parent node to insert child into.
child The child node to insert into parent.

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

Inserts data into a node.

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

xmlnode* xmlnode_new ( const char *  name  ) 

Creates a new xmlnode.

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

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

Creates a new xmlnode child.

Parameters:
parent The parent node.
name The name of the child node.
Returns:
The new child node.

void xmlnode_remove_attrib ( xmlnode node,
const char *  attr 
)

Removes an attribute from a node.

Parameters:
node The node to remove an attribute from.
attr The attribute to remove.

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

Removes a namespaced attribute from a node.

Parameters:
node The node to remove an attribute from
attr The attribute to remove
xmlns The namespace of the attribute to remove

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

Sets an attribute for a node.

Parameters:
node The node to set an attribute for.
attr The name of the attribute.
value The value of the attribute.

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:
node The node to set an attribute for.
attr The name of the attribute to set
xmlns The namespace of the attribute to ste
value The value of the attribute

void xmlnode_set_namespace ( xmlnode node,
const char *  xmlns 
)

Sets the namespace of a node.

Parameters:
node The node to qualify
xmlns The namespace of the node

char* xmlnode_to_formatted_str ( xmlnode node,
int *  len 
)

Returns the node in a string of human readable xml.

Parameters:
node The starting node to output.
len Address 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.

char* xmlnode_to_str ( xmlnode node,
int *  len 
)

Returns the node in a string of xml.

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