Main Page Modules Namespace List Data Structures File List Data Fields Examples

# Node
[DOM]

## Modules

Comment
Document
Element
Text

## Data Structures

struct | _dom_node

## Defines

#define | DOM_NDOE_TYPE_INVALID 0x0000
#define | DOM_NODE_TYPE_DOCUMENT 0x0001
#define | DOM_NODE_TYPE_ELEMENT 0x0002
#define | DOM_NODE_TYPE_ATTRIBUTE 0x0003
#define | DOM_NODE_TYPE_TEXT 0x0004
#define | DOM_NODE_TYPE_COMMENT 0x0005

## Typedefs

typedef _dom_node | DOM_NODE

## Functions

DOM_NODE * | domNodeNew (unsigned long type, const char *name, const char *value)
void | domNodeDestroySpecific (DOM_NODE *node)
void | domNodeDestroy (DOM_NODE *node)
void | domNodeAppendChild (DOM_NODE *parent, DOM_NODE *child)
void | domNodeAppendSibling (DOM_NODE *node, DOM_NODE *sibling)
void | domNodeRemoveChild (DOM_NODE *parent, DOM_NODE *child)
DOM_NODE * | domNodeGetFirstChild (DOM_NODE *node)
DOM_NODE * | domNodeGetPreviousSibling (DOM_NODE *node)
DOM_NODE * | domNodeGetNextSibling (DOM_NODE *node)
void | domNodeSetName (DOM_NODE *node, const char *name)
const char * | domNodeGetName (DOM_NODE *node)
void | domNodeSetValue (DOM_NODE *node, const char *value)
void | domNodeSetValueVariant (DOM_NODE *node, enum VariantType type, void *value, unsigned long valueSize)
const char * | domNodeGetValue (DOM_NODE *node)
void * | domNodeGetValueVariant (DOM_NODE *node, enum VariantType type)
DOM_NODE * | domNodeFindNodeByName (DOM_NODE *node, const char *name)
_dom_node_list * | domNodeFindNodesByName (DOM_NODE *node, const char *name)
void | domNodeFindNodesByName_r (struct _dom_node_list *nodeList, DOM_NODE *node, const char *name)
void | domNodeSerializeToFile (DOM_NODE *node, const char *fileName)
void | domNodeSerializeToFd (DOM_NODE *node, FILE *fd)
unsigned long | domNodeSerializeToString (DOM_NODE *node, char **string)
void | domNodeSerializeToString_r (DOM_NODE *node, char **string, unsigned long *stringLength)

## Detailed Description

Core DOM node methods.

## Typedef Documentation

typedef struct _dom_node DOM_NODE

| The most basic form of all DOM nodes.

## Function Documentation

void domNodeAppendChild | ( | DOM_NODE * | parent,
|  | DOM_NODE * | child
| ) |

Appends a child to a node.

Parameters:

  parent | [in] The parent that will have a child appended to it.
  child | [in] The child node to append.

void domNodeAppendSibling | ( | DOM_NODE * | node,
|  | DOM_NODE * | sibling
| ) |

Appends a sibling to a node.

Parameters:

  node | [in] The node to have a sibling appended to it.
  sibling | [in] The sibling to append.

void domNodeDestroy | ( | DOM_NODE * | node | ) |

Recursively destroys a given node.

Parameters:

  node | [in] The node to destroy.

Examples:
  variant.c.

void domNodeDestroySpecific | ( | DOM_NODE * | node | ) |

Destroys a specific node. This is only used internally.

Parameters:

  node | [in] The node to deinitialize.

DOM_NODE* domNodeFindNodeByName | ( | DOM_NODE * | node,
|  | const char * | name
| ) |

Finds the first node (recursively) that matches the given name.

Parameters:

  node | [in] The node to search on.
  name | [in] The name of the node being searched for.

Returns:
  If a node with the same name as the one specified is found, a valid node pointer will be returned. Otherwise, NULL is returned.

struct _dom_node_list* domNodeFindNodesByName | ( | DOM_NODE * | node,
|  | const char * | name
| ) |

Finds all nodes (recursively) that match the gievn name.

Parameters:

  node | [in] The node to search on.
  name | [in] The name of the node being searched for.

Returns:
  If any nodes are found that match the given name, a valid DOM_NODELIST is returned. Otherwise, NULL is returned.

DOM_NODE* domNodeGetFirstChild | ( | DOM_NODE * | node | ) |

Returns the first child of a node.

Parameters:

  node | [in] The node to get the first child of.

Returns:
  If the node has a first child, a valid node will be returned. Otherwise, NULL is returned.

const char* domNodeGetName | ( | DOM_NODE * | node | ) |

Returns the name associated with the node.

Parameters:

  node | [in] The node to get the name of.

Returns:
  If the node has a name, a valid null terminated string is returned. Otherwise, NULL is returned.

DOM_NODE* domNodeGetNextSibling | ( | DOM_NODE * | node | ) |

Returns the next sibling relative to the given node.

Parameters:

  node | [in] The node to get the next sibling of.

Returns:
  If the node has a next sibling, a valid node will be returned. Otherwise, NULL is returned.

DOM_NODE* domNodeGetPreviousSibling | ( | DOM_NODE * | node | ) |

Returns the previous sibling relative to the given node.

Parameters:

  node | [in] The node to get the previous sibling of.

Returns:
  If the node has a previous sibling, a vaild node will be returned. Otherwise, NULL is returned.

const char* domNodeGetValue | ( | DOM_NODE * | node | ) |

Returns the string value associated with the node.

Variant type manipulation (For information on variant manipulation)

Parameters:

  node | [in] The node to get the value of.

Returns:
  If the node has a value, a valid null terminated string is returned. Otherwise, NULL is returned.

void* domNodeGetValueVariant | ( | DOM_NODE * | node,
|  | enum VariantType | type
| ) |

Returns the variant value associated with the string.

Variant type manipulation (For information on variant manipulation)

Parameters:

  node | [in] The node to get the value of.
  type | [in] The type used to interpret the value.

Returns:
  The return value is dependant upon the type argument.

DOM_NODE* domNodeNew | ( | unsigned long | type,
|  | const char * | name,
|  | const char * | value
| ) |

Constructs a basic node from the provided parameters.

Type can be any one of the following:

- DOM_NODE_TYPE_INVALID
  The node is not valid.
- DOM_NODE_TYPE_DOCUMENT
  The node is a document node.
- DOM_NODE_TYPE_ELEMENT
  The node is an element node.
- DOM_NODE_TYPE_ATTRIBUTE
  The node is an attribute node.
- DOM_NODE_TYPE_TEXT
  The node is a text node.
- DOM_NODE_TYPE_COMMENT
  The node is a comment node.

Parameters:

  type | [in] The type of node.
  name | [in] The arbitrary name of the node.
  value | [in] THe arbitrary value of the node.

Returns:
  On success, a pointer to an initialized DOM node is returned. Otherwise, NULL is returned.

void domNodeRemoveChild | ( | DOM_NODE * | parent,
|  | DOM_NODE * | child
| ) |

Removes a child.

Parameters:

  parent | [in] The parent to have the child removed from.
  child | [in] The child node that is to be removed.

void domNodeSerializeToFd | ( | DOM_NODE * | node,
|  | FILE * | fd
| ) |

Serializes a given node to a file descriptor.

Parameters:

  node | [in] The node to serialize.
  fd | [in] The destination file descriptor.

Examples:
  testhtml.c.

void domNodeSerializeToFile | ( | DOM_NODE * | node,
|  | const char * | fileName
| ) |

Serializes a given node to a file.

Parameters:

  node | [in] The node to serialize.
  fileName | [in] The destination file name.

unsigned long domNodeSerializeToString | ( | DOM_NODE * | node,
|  | char ** | string
| ) |

Serializes a given node to a string. This string must be deallocate with free() when it is dnoe being used.

Parameters:

  node | [in] The node to serialize.
  string | [out] A pointer to a pointer that will hold the null terminated SGML string.

Returns:
  On success, a value greater than zero is returned that represents the length of the SGML string. Otherwise, zero is returned.

Examples:
  testxml.c.

void domNodeSetName | ( | DOM_NODE * | node,
|  | const char * | name
| ) |

Sets the name of the node.

Parameters:

  node | [in] The node to have the name set on.
  name | [in] The name to set the node to.

void domNodeSetValue | ( | DOM_NODE * | node,
|  | const char * | value
| ) |

Sets the string value of the node.

Parameters:

  node | [in] The node to have the value set on.
  value | [in] The null-terminated string to set the value to.

void domNodeSetValueVariant | ( | DOM_NODE * | node,
|  | enum VariantType | type,
|  | void * | value,
|  | unsigned long | valueSize
| ) |

Sets the value of the node from a variant type.

Parameters:

  node | [in] The node to have the value set on.
  type | [in] The type used to interpret the value argument.
  value | [in] A pointer to the raw data.
  valueSize | [in] The size, in bytes, of value.