libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches
CMUTIL_XmlNode Struct Reference

XML node manipulation. More...

Data Fields

CMUTIL_StringArray *(* GetAttributeNames )(const CMUTIL_XmlNode *node)
 Get all attribute names of this node.
 
CMUTIL_String *(* GetAttribute )(const CMUTIL_XmlNode *node, const char *key)
 Get the value of an attribute by key.
 
void(* SetAttribute )(CMUTIL_XmlNode *node, const char *key, const char *value)
 Set the value of an attribute by key.
 
size_t(* ChildCount )(const CMUTIL_XmlNode *node)
 Get the number of child nodes.
 
void(* AddChild )(CMUTIL_XmlNode *node, CMUTIL_XmlNode *child)
 Add a child node to this node.
 
CMUTIL_XmlNode *(* ChildAt )(const CMUTIL_XmlNode *node, uint32_t index)
 Get the child node at a specific index.
 
CMUTIL_XmlNode *(* GetParent )(const CMUTIL_XmlNode *node)
 Get the parent node of this node.
 
const char *(* GetName )(const CMUTIL_XmlNode *node)
 Get the name of this node.
 
void(* SetName )(CMUTIL_XmlNode *node, const char *name)
 Set the name of this node.
 
CMXmlNodeKind(* GetType )(const CMUTIL_XmlNode *node)
 Get the text content of this node.
 
CMUTIL_String *(* ToDocument )(const CMUTIL_XmlNode *node, CMBool beutify)
 Convert this node and its children to an XML document string.
 
void(* SetUserData )(CMUTIL_XmlNode *node, void *udata, void(*freef)(void *))
 Set user data associated with this node.
 
void *(* GetUserData )(const CMUTIL_XmlNode *node)
 Get the user data associated with this node.
 
void(* Destroy )(CMUTIL_XmlNode *node)
 Destroy this XML node and free its resources.
 

Detailed Description

XML node manipulation.

Field Documentation

◆ GetAttributeNames

CMUTIL_StringArray *(* CMUTIL_XmlNode::GetAttributeNames) (const CMUTIL_XmlNode *node)

Get all attribute names of this node.

The caller is responsible for freeing the returned string array.

Parameters
nodeThis XML node object.
Returns
A string array containing all attribute names.

◆ GetAttribute

CMUTIL_String *(* CMUTIL_XmlNode::GetAttribute) (const CMUTIL_XmlNode *node, const char *key)

Get the value of an attribute by key.

The caller is responsible for freeing the returned string.

Parameters
nodeThis XML node object.
keyThe attribute key.
Returns
The value of the attribute as a string, or NULL if not found.

◆ SetAttribute

void(* CMUTIL_XmlNode::SetAttribute) (CMUTIL_XmlNode *node, const char *key, const char *value)

Set the value of an attribute by key.

Parameters
nodeThis XML node object.
keyThe attribute key.
valueThe value to set for the attribute.

◆ ChildCount

size_t(* CMUTIL_XmlNode::ChildCount) (const CMUTIL_XmlNode *node)

Get the number of child nodes.

Parameters
nodeThis XML node object.
Returns
The number of child nodes.

◆ AddChild

void(* CMUTIL_XmlNode::AddChild) (CMUTIL_XmlNode *node, CMUTIL_XmlNode *child)

Add a child node to this node.

The ownership of the child node is transferred to this node.

Parameters
nodeThis XML node object.
childThe child node to add.

◆ ChildAt

CMUTIL_XmlNode *(* CMUTIL_XmlNode::ChildAt) (const CMUTIL_XmlNode *node, uint32_t index)

Get the child node at a specific index.

The caller is responsible for not modifying or destroying the returned child node.

Parameters
nodeThis XML node object.
indexThe index of the child node to retrieve.
Returns
The child node at the specified index, or NULL if index is out of bounds.

◆ GetParent

CMUTIL_XmlNode *(* CMUTIL_XmlNode::GetParent) (const CMUTIL_XmlNode *node)

Get the parent node of this node.

The caller is responsible for not modifying or destroying the returned parent node.

Parameters
nodeThis XML node object.
Returns
The parent node, or NULL if this node has no parent.

◆ GetName

const char *(* CMUTIL_XmlNode::GetName) (const CMUTIL_XmlNode *node)

Get the name of this node.

For a text node the "name" is the text itself.

Parameters
nodeThis XML node object.
Returns
The name of the node as a C-style string. It belongs to the node.

◆ SetName

void(* CMUTIL_XmlNode::SetName) (CMUTIL_XmlNode *node, const char *name)

Set the name of this node.

Parameters
nodeThis XML node object.
nameThe new name for the node.

◆ GetType

CMXmlNodeKind(* CMUTIL_XmlNode::GetType) (const CMUTIL_XmlNode *node)

Get the text content of this node.

The caller is responsible for freeing the returned string.

Parameters
nodeThis XML node object.
Returns
The text content of the node as a string.

◆ ToDocument

CMUTIL_String *(* CMUTIL_XmlNode::ToDocument) (const CMUTIL_XmlNode *node, CMBool beutify)

Convert this node and its children to an XML document string.

The caller is responsible for freeing the returned string.

Parameters
nodeThis XML node object.
beutifyWhether to format the output string for readability.
Returns
The XML document string representation of this node.

◆ SetUserData

void(* CMUTIL_XmlNode::SetUserData) (CMUTIL_XmlNode *node, void *udata, void(*freef)(void *))

Set user data associated with this node.

The user data can be any pointer type. A callback function can be provided to free the user data when the node is destroyed.

Parameters
nodeThis XML node object.
udataThe user data to associate with this node.
freefA callback function to free the user data when no longer needed.

◆ GetUserData

void *(* CMUTIL_XmlNode::GetUserData) (const CMUTIL_XmlNode *node)

Get the user data associated with this node.

Parameters
nodeThis XML node object.
Returns
The user data associated with this node.

◆ Destroy

void(* CMUTIL_XmlNode::Destroy) (CMUTIL_XmlNode *node)

Destroy this XML node and free its resources.

Parameters
nodeThis XML node object.

The documentation for this struct was generated from the following file: