Re: [xml] Re: Converting text to CDATA

On Sat, May 07, 2005 at 08:17:11PM -0700, Octavian Afilipoai wrote:
For some reason my message was send corrupted the
first time

What is the best way to use CDATA blocks to
encapsulate the text?

Right now I do something like this in order to fill in
my_node with some_string:

xmlNodeSetContent(my_node, BAD_CAST

I could manually add the CDATA identifiers like

xmlNodeSetContent(my_node,BAD_CAST ("<![CDATA +
some_string + "]]").c_str());

  that's wrong. You just generate a broken tree, and even when 
serializing that should not work as < would be escaped.

but I am thinking that libxml should supply some
utilities to do this auautomatically and I just could
not find them

xmlNodePtr XMLCALL xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len);

  If you use the search engine on selecting the XML API and
lookup for CData it's show up on the 12th line:

"10 xmlNewCDataBlock function tree Creation of a new node containing a CDATA block"


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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