Re: [xml] Reading CDATA



On Wed, Sep 17, 2008 at 06:48:37PM +0200, Hartmut Sbosny wrote:
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 

  You just can't using that API. 

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?

wei:~/XML -> cat tst.xml 
<data>
   <![CDATA[...]]>
</data>

wei:~/XML -> xmllint --debug tst.xml
DOCUMENT
version=1.0
URL=tst.xml
standalone=true
  ELEMENT data
    TEXT compact
      content=    
    CDATA_SECTION
      content=...
    TEXT compact
      content= 
wei:~/XML -> 

 navigate in the tree and grab the data as content-> from the second
child of your containing element

Daniel 

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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