List Info

Thread: xmlNodeGetContent and xmlNodeSetContent




xmlNodeGetContent and xmlNodeSetContent
user name
2007-02-02 04:09:20
Hi All,

I'm new to programming with libxml2. Please, tell me about
these strange behaviours.

Very very simple, standalone xml:

<?xml version="1.0"?>
<data param="hello">
   <msg ev="exit" p="1"/>
   text content
   <text label="foo"/>
   <t label="red">
     <x>ciao</x>
   </t>
</data>

xmlNodeGetContent for node <data>:
----


   text content


     ciao


----

Ok, the Content means all text nodes' value concatenated
under the node (or the value if 
it is a text node, but it is XML_ELEMENT_NODE for now). The
blank lines come from the n 
and t in the source xml.
Why is "ciao" included in <data>'s content?


xmlNodeSetContent:

I assumed that this function drops all text nodes under and
appends only one new text node 
with the given value. In short, replaces the text content of
a node.
Why does it drop _all_ child nodes, including
XML_ELEMENT_NODEs and so deleting the whole 
subtree?

Thanks in advance,
Laszlo

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )