[xml] Reading CDATA



Hello,
I am fresh to libxml. I want to read an xml file containing
the part
        <data>
                <![CDATA[...]]>
        </data>

Currently I use the xmlParseDoc() interface. My first try was to read the 
<data> node string via xmlNodeListGetString(). This returns something 
like "___...___", i.e. the CDATA content (...) wrapped by the white space 
(__) around the CDATA tag. Following I removed the white space "by hand", but 
this would fail, if the CDATA content itself starts or ends with white space. 
My next try was to parse through the children nodes of the <data> node and 
reading the node strings. This gives the three strings
        "___...___"
        "...___"
        "___"
(what I, btw, not realy understand - why contains the first node the others?). 
From there I could in princple extract the pure "..." content by subtracting 
the trailing white space node string, but it seems to me there should exist 
an easier libxml way to read the CDATA content?

Thanks,
Hartmut



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