Re: [xml] Interating over all children of a given node?
- From: Daniel Veillard <veillard redhat com>
- To: Gabriel Ambuehl <gabriel_ambuehl buz ch>
- Cc: xml xmlsoft org
- Subject: Re: [xml] Interating over all children of a given node?
- Date: Tue, 12 Jun 2001 09:25:42 -0400
On Tue, Jun 12, 2001 at 03:10:50PM +0200, Gabriel Ambuehl wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hello,
I wonder what the easiest way to iterate over all direct children of
a
node is. Is there any possibility to obtain a NodeSet of the children
to allow easy iteration?
xmlNodePtr current, child;
current = ....
child = current->children;
while (child != NULL) {
/* handle child, especially looking at child->type first */
child = child->next;
}
I'm not sure adding a function would be any cleaner, one would need to
allocate the memory for the array, let the user free it (dangerous or
one need to handle the case where the caller allocate the array but
this may be too small ...). Iterating on an array is only barely simpler
the only distinctive advantage would be random access.
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]