RAVE
rave_simplexml.h File Reference

Simple XML object frontend to expat. More...

#include "rave_attribute.h"
#include "rave_object.h"
#include <stdio.h>

Go to the source code of this file.

Typedefs

typedef struct _SimpleXmlNode_t SimpleXmlNode_t
 

Functions

SimpleXmlNode_tSimpleXmlNode_parseFile (const char *filename)
 The parser function for parsing the xml-file into a node tree.
 
void SimpleXmlNode_setParent (SimpleXmlNode_t *self, SimpleXmlNode_t *parent)
 Sets the parent for this node.
 
SimpleXmlNode_tSimpleXmlNode_getParent (SimpleXmlNode_t *self)
 Returns the parent for this node.
 
int SimpleXmlNode_setName (SimpleXmlNode_t *self, const char *name)
 Sets the tag name of this node.
 
const char * SimpleXmlNode_getName (SimpleXmlNode_t *self)
 Returns the tag name of this node.
 
int SimpleXmlNode_setText (SimpleXmlNode_t *self, const char *text, int len)
 Sets the text.
 
int SimpleXmlNode_addText (SimpleXmlNode_t *self, const char *text, int len)
 Adds text.
 
const char * SimpleXmlNode_getText (SimpleXmlNode_t *self)
 Returns the text.
 
int SimpleXmlNode_addChild (SimpleXmlNode_t *self, SimpleXmlNode_t *child)
 Adds a child to this node.
 
void SimpleXmlNode_remove (SimpleXmlNode_t *self, SimpleXmlNode_t *child)
 Removes the given child from the children list.
 
int SimpleXmlNode_getNumberOfChildren (SimpleXmlNode_t *self)
 Returns the number of children.
 
SimpleXmlNode_tSimpleXmlNode_getChild (SimpleXmlNode_t *self, int index)
 Returns the child at specified index.
 
SimpleXmlNode_tSimpleXmlNode_getChildByName (SimpleXmlNode_t *self, const char *name)
 Returns the child with the given name.
 
int SimpleXmlNode_addAttribute (SimpleXmlNode_t *self, const char *key, const char *value)
 Adds an attribute to a node.
 
const char * SimpleXmlNode_getAttribute (SimpleXmlNode_t *self, const char *key)
 Returns the attribute value for the specified attribute.
 
int SimpleXmlNode_write (SimpleXmlNode_t *self, FILE *fp)
 Writes the node to the file pointer.
 
SimpleXmlNode_tSimpleXmlNode_create (SimpleXmlNode_t *parent, const char *name)
 Creates a xml node.
 

Variables

RaveCoreObjectType SimpleXmlNode_TYPE
 Type definition to use when creating a rave object.
 

Detailed Description

Simple XML object frontend to expat.

This object supports RAVE_OBJECT_CLONE.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2010-12-08

Function Documentation

◆ SimpleXmlNode_addAttribute()

int SimpleXmlNode_addAttribute ( SimpleXmlNode_t * self,
const char * key,
const char * value )

Adds an attribute to a node.

Parameters
[in]self- self
[in]key- the name of the attribute
[in]value- the value of the attribute
Returns
1 on success otherwise 0

◆ SimpleXmlNode_addChild()

int SimpleXmlNode_addChild ( SimpleXmlNode_t * self,
SimpleXmlNode_t * child )

Adds a child to this node.

Parameters
[in]self- self
[in]child- the child
Returns
1 on success otherwise 0

◆ SimpleXmlNode_addText()

int SimpleXmlNode_addText ( SimpleXmlNode_t * self,
const char * text,
int len )

Adds text.

Parameters
[in]self- self
[in]text- the text
[in]len- the length of the text
Returns
1 on success otherwise 0

◆ SimpleXmlNode_create()

SimpleXmlNode_t * SimpleXmlNode_create ( SimpleXmlNode_t * parent,
const char * name )

Creates a xml node.

If node is given, the created node will be created as a child to that node otherwise it will be created as a root node.

Parameters
[in]parent- the parent node (MAY BE NULL)
[in]name- the name of the node (MAY BE NULL)
Returns
the node on success or NULL on failure

◆ SimpleXmlNode_getAttribute()

const char * SimpleXmlNode_getAttribute ( SimpleXmlNode_t * self,
const char * key )

Returns the attribute value for the specified attribute.

Parameters
[in]self- self
[in]key- the name of the attribute
Returns
the value

◆ SimpleXmlNode_getChild()

SimpleXmlNode_t * SimpleXmlNode_getChild ( SimpleXmlNode_t * self,
int index )

Returns the child at specified index.

Parameters
[in]self- self
[in]index- the index
Returns
the child node

◆ SimpleXmlNode_getChildByName()

SimpleXmlNode_t * SimpleXmlNode_getChildByName ( SimpleXmlNode_t * self,
const char * name )

Returns the child with the given name.

Parameters
[in]self- self
[in]name- the name of the node
Returns
the child node

◆ SimpleXmlNode_getName()

const char * SimpleXmlNode_getName ( SimpleXmlNode_t * self)

Returns the tag name of this node.

Parameters
[in]self- self
Returns
the tag name

◆ SimpleXmlNode_getNumberOfChildren()

int SimpleXmlNode_getNumberOfChildren ( SimpleXmlNode_t * self)

Returns the number of children.

Parameters
[in]self- self
Returns
the number of children

◆ SimpleXmlNode_getParent()

SimpleXmlNode_t * SimpleXmlNode_getParent ( SimpleXmlNode_t * self)

Returns the parent for this node.

Parameters
[in]self- self
Returns
the parent

◆ SimpleXmlNode_getText()

const char * SimpleXmlNode_getText ( SimpleXmlNode_t * self)

Returns the text.

Parameters
[in]self- self
Returns
the text (if any)

◆ SimpleXmlNode_parseFile()

SimpleXmlNode_t * SimpleXmlNode_parseFile ( const char * filename)

The parser function for parsing the xml-file into a node tree.

Parameters
[in]filename- the file to parse
Returns
a node on success otherwise failure

◆ SimpleXmlNode_remove()

void SimpleXmlNode_remove ( SimpleXmlNode_t * self,
SimpleXmlNode_t * child )

Removes the given child from the children list.

Parameters
[in]self- self
[in]child- the node to remove

◆ SimpleXmlNode_setName()

int SimpleXmlNode_setName ( SimpleXmlNode_t * self,
const char * name )

Sets the tag name of this node.

Parameters
[in]self- self
[in]name- the name of the node
Returns
1 on success otherwise 0

◆ SimpleXmlNode_setParent()

void SimpleXmlNode_setParent ( SimpleXmlNode_t * self,
SimpleXmlNode_t * parent )

Sets the parent for this node.

NOTE! The parent is just a raw pointer assignment so be careful when using it.

Parameters
[in]self- self
[in]parent- the parent

◆ SimpleXmlNode_setText()

int SimpleXmlNode_setText ( SimpleXmlNode_t * self,
const char * text,
int len )

Sets the text.

The added text will be stripped of leading and trailing whitespaces (space, tab, newline and carriage return).

Parameters
[in]self- self
[in]text- the text
[in]len- the length of text
Returns
1 on success otherwise 0

◆ SimpleXmlNode_write()

int SimpleXmlNode_write ( SimpleXmlNode_t * self,
FILE * fp )

Writes the node to the file pointer.

Parameters
[in]self- self
[in]fp- the file pointer to write to
Returns
1 on success otherwise 0

Variable Documentation

◆ SimpleXmlNode_TYPE

RaveCoreObjectType SimpleXmlNode_TYPE
extern

Type definition to use when creating a rave object.