Re: [xml] Problems with the character & and saving/loading XML files



On 2002.04.19 15:20 Daniel Gehriger wrote:


The following two characters must be escaped: '<' and '&'.
You could also use a CDATA section, like this:
<mydata><![CDATA[   ANY DATA   ]]></mydata>
, but then you mustn't use "]]>" inside the CDATA section, and there's
no way to escape this sequence. You better don't use CDATA for this
reason.  Here's a link with more information:

http://www.w3schools.com/xml/xml_cdata.asp

Okay, thanks a lot..
How do I use <![CDATA[ in the libxml ? When I do something
like this then "<" and ">" will get escaped :

gchar *data;
data = g_strdup_printf("<![CDATA[%s]]>", item->data);
xmlNewChild (itemnode,NULL,"data", data);

And if I don't want to use the <![CDATA[ ]]> tag. What
would be the best way to search/replace the "special"
characters in C ? Normal regular expression, sed like
search/replace ? s/&/&amp;/g ?


--
Philip Van Hoof



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]