axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
char * axl_node_content_copy_and_escape ( const char *  content,
int  content_size,
int  additional_size 

Allows to perform a copy from the content provided, doing an xml character escaping for non allowed values (&, <, >, ' and ").

This function must be used with axl_node_has_invalid_chars to check if the content has escapable chars an to get the additional content that must be allocated by this function.

Here is an example:

1 char * content = "Some content with invalid chars & < >";
2 int additional_size;
3 char * new_content
5 if (axl_node_has_invalid_chars (content, strlen (content), &additional_size)) {
6  // found that the string has invalid chars, escape them
7  new_content = axl_node_content_copy_and_escape (content, strlen (content), additional_size);
8 }
contentThe content to be escaped. If this parameter is NULL, the function returns NULL.
content_sizeThe content size for the first parameter.
additional_sizeThe additional size calculated from axl_node_has_invalid_chars.
A newly allocated string with all characters escaped. Use axl_free to dealloc the result.

References axl_false, and axl_return_val_if_fail.