Re: [xml] xmlNodeGetContent() completely recursive?



On Mon, Oct 22, 2001 at 03:25:25PM +0200, Henke, Markus wrote:
But there's one problem: The behavior of xmlNodeGetContent()  is
"completely" recursiv,
that is, it aggregates not only the child (TEXT and ENTITY_REF) nodes but
also the
grandchild nodes, the grand-grandchild nodes etc.
So, if i call xmlNodeGetContent() on a root element, i'll get an aggregation
of all TEXT
nodes enclosed by the document.
Well, i think this behavior is "by design", but is there a similar method

  yes

that provides
only the aggregation of the 1st generation (TEXT-  and ENTITY_REF-) child
nodes of a given node?

  no, simply walk the node "children" list and call xmlNodeGetContent()
on the elements you want to pick.

  From a structured document perspective and since you seems to have
mixed content, 

   text  <child A>  text2  <child B>  text3

  Extracting a concatenation of text + text2 + text3 without the content
of the node children really makes little sense. I'm tempted to say that
your DTD is not well designed if you have to do this.

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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