[xml] xmlNodeGetContent and xmlNodeSetContent



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




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