On 10/29/06, Oliver Heyme <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have XML-files doing something like this:
>
> <array>
> <item data="..."/>
> <item data="..."/>
> ...
> <item data="..."/>
> <item data="..."/>
> </array>
>
> and I am using the xmlReader!
>
> The problem is that I would like to know how many "item" elements are
> between the array-tags!
> Is there any possibility to do this without adding a "size"-attribute
> to the opening array-tag!
It depends on for what you need such "size".
If it's just for information, then add some counter, reset it to zero
at the <array>, increment on the every <item/> and do what you want at
the </array>.
If "size" id needed for you for pre-allocating C-style array
(something like
item_t array[size];
or
item_t* array = calloc(size, sizeof(item_t));
), then just use dynamically-resizable arrays.
For example, C++ std::vector if you use C++, or GArray or GPtrArray
from Glib if your language is plain C...
--
Andrew W. Nosenko <[EMAIL PROTECTED]>
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml