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







Hi!

i'm working on a high-level c++ wrapper for libxml and came across the
following problem when setting contents of nodes.

assuming i have the following xml-document:

<a>
      <b>
            <c>content</c>
      </b>
</a>

and i want to set the content of the node "a" so the document looks like
this:

<a>
      a's content
      <b>
            <c>content</c>
      </b>
</a>

my code for achieving this goal is:

...

      xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");

      xmlNodePtr node_a = xmlNewNode(NULL, BAD_CAST "a");
      xmlNodePtr node_b = xmlNewNode(NULL, BAD_CAST "b");
      xmlNodePtr node_c = xmlNewNode(NULL, BAD_CAST "c");

      xmlDocSetRootElement(doc, node_a);
      xmlAddChild(node_a, node_b);
      xmlAddChild(node_b, node_c);

      xmlNodeSetContent(node_c, BAD_CAST "content");

      xmlNodeSetContent(node_a, BAD_CAST "a's content");

...

but unfortunately, after the second call to xmlNodeSetContent() all the
childs of "a" disappear and if i dump the xml document i get this back:

<a>a's content</a>

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

any help will be greatly appreciated!

thanks a lot in advance

markus


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
communications.





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