Re: Re: [xml] child nodes disappear after call to xmlNodeSetContent()


thanks a lot for your reply, this put me on the right track!

i changed the calls to xmlSetNodeContent on the element-nodes to

      xmlNodePtr textNode1 = xmlNewText(BAD_CAST "content");
      xmlAddChild(node_c, textNode1);

      xmlNodePtr textNode2 = xmlNewText(BAD_CAST "a's content");
      xmlAddChild(node_a, textNode2);

and now it behaves correctly!

assuming i have a class which wraps an xmlNodePtr, i could automatically
create an aditional empty textnode for every element node. if i want set or
change the content, i call xmlSetNodeContent on the underlying textnode and
it should work. am i right in this point?

best wishes


On 18.01.2005 14:15:52 danilo wrote:
Today at 13:41, Markus STROBL wrote:

after every call to xmlNodeSetContent, all the childs are removed!

This way, you're basically removing references to all the other
subnodes, and inserting a single text node.  Btw, how do you think you
could get something like this:

if you had <a><b>blah</b></a>?  What would you expect SetContent to do
in such cases?  (I'm just showing that this behavior is simply logical)

You most likely want to construct 'text' nodes, and insert them
instead of using SetContent: watch out for keeping proper relations
(->children, ->next, ->prev) between nodes.  I know this only from
Python bindings, so I cannot help you with concrete code.


Der Austausch von Nachrichten mit o.a. Absender via e-mail dient
ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen dürfen
über dieses Medium nicht ausgetauscht werden.

Correspondence with a.m. sender via e-mail is only for information
purposes. This medium is not to be used for the exchange of legally-binding

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