Re: [xml] xmlNodeSetContent that doesn't wipe out child elements?

Date view Thread view Subject view Author view

From: Harry Blundell (harry@halcyoninc.com)
Date: Mon Oct 23 2000 - 09:46:16 EDT


Thanks for your answer, but I think that either I wasn't clear, or I'm
missing something. I have no problem with the way the mixed content of
an element is stored. My problem is with my understanding of
xmlNodeSetContent: before adding new content to an element node, it
removes ALL child nodes - both text nodes (understandable) and element
nodes (no so understandable, at least to me). I'm looking for a function
that replaces the child text nodes (and I'm not too concerned with where
the new text nodes go - at the end would be fine), while leaving the
child element nodes intact.

I'll write such a function if I have to - I just want to be sure that I'm
not reinventing the wheel.

Thanks,

Harry
----------------------------------------------------------------------
Harry Blundell Halcyon Inc. URL: http://www.HalcyonInc.com
2300 Yonge St., Suite 1801, Box 2419, Toronto ON M4P 1E4, Canada.
PHONE: 416-932-4631 FAX: 416-932-4711 EMAIL: harry@HalcyonInc.com

On Sat, 21 Oct 2000, TOM wrote:

> On 21/10/2000 22:58:33 Harry Blundell wrote:
> > My reading of xmlNodeSetContent is that it wipes out
> > node->content, and all of node's child nodes, and then acts
> > differently to save the new content depending on whether the node
> > is a comment (in which case it uses node->content) or an element
> > (in which case it creates child nodes to hold the new content.
> >
> > This doesn't work so well for elements that have mixed content
> > (both text content, and child elements). Is there a function that
> > replaces the content of an element, while leaving its child
> > elements alone, or do I have to write one?
>
> Mixed content doesn't use node->content but text nodes between element
> nodes.
> Imagine you have node->content not NULL *AND* child elements. When you
> need to "serialize" the tree, where do you put node->content in relation
> with child elements ? before ? after ? somewhere between ? There's no
> issue!
>
> If you have child elements, text content is represented by text nodes
> (XML_TEXT_NODE) between your child elements (XML_ELEMENT_NODES).
> You can figure out this passing the --debug option to xmllint.
>
> HTH
> ----
> Message from the list xml@rpmfind.net
> Archived at : http://xmlsoft.org/messages/
> to unsubscribe: echo "unsubscribe xml" | mail majordomo@rpmfind.net

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 10:43:36 EDT