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

Allows to perform a copy for the content provided, doing an xml character escaping for non allowed values (&, <, >, ' and ") taking into consideration the content will be placed inside a <![CDATA[..]]> declaration.

This function must be used with axl_node_has_invalid_chars_cdata 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_cdata (content, strlen (content), &additional_size)) {
6  // found that the string has invalid chars, escape them
7  new_content = axl_node_content_copy_and_escape_cdata (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_cdata.
A newly allocated string with all characters escaped. Use axl_free to dealloc the result.

References axl_return_val_if_fail, and axl_true.