RE: [xml] xmlNodeGetContent() completely recursive?

Hi Daniel,

-----Original Message-----
From: Henke, Markus 
Sent: Monday, October 22, 2001 4:39 PM
To: 'xml gnome org'
Cc: 'veillard redhat com'
Subject: RE: [xml] xmlNodeGetContent() completely recursive?

-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com]
Sent: Monday, October 22, 2001 3:47 PM
To: Henke, Markus
Cc: 'xml gnome org'
Subject: 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


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 
on the elements you want to pick.

What a pity. Won't work for me...

Nonsense, for sure it'll work.
Just got it completely wrong. Silly me...   8]

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

   text  <child A>  text2  <child B>  text3

Yep, possible scenario.
Extracting a concatenation of text + text2 + text3 without 
the content of the node children really makes little sense.


Another point: If i make a complete parse of an unknown document
structure (without DTD), e.g.:


(no mixed content!),
does it make sense to get "Grandchild's content" when i call
Wouldn't it be useful to have a method that provides
xmlNodeGet???(root)= "",
xmlNodeGet???(child)= "",
xmlNodeGet???(grandchild)= "Grandchild's content"?

I'm tempted to say that
your DTD is not well designed if you have to do this.

Granted. And if it would be "MY" DTD, i won't allow mixed
content at all.
But in fact i've to deal with several kind of documents,
potentially without DTD/validation and without influence
on the potential structure.

Thanx & Ciao, Markus
Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml Gnome XML XSLT toolkit | Rpmfind RPM search engine

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