Re: [xml] xmlList* functionality
- From: Gary Pennington <Gary Pennington sun com>
- To: Smith Baylor <sbaylor gmail com>
- Cc: xml gnome org
- Subject: Re: [xml] xmlList* functionality
- Date: Wed, 15 Dec 2004 12:55:13 +0000
On Mon, Dec 13, 2004 at 10:47:11AM -0800, Smith Baylor wrote:
Hi,
Are there any examples of using
xmlListCreate, xmlListInsert, xmlListWalk and xmlListWalker
xmlListPtr list;
list = xmlListCreate(NULL, NULL);
if (! (xmlListInsert (list, (void *) "test") ) ) {
printf ("error\n");
}
I am getting error in the o/p. Any clues as to what I am doing wrong?
Any samples for all the List functions is greatly appreciated.
Thanks
Smith
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
A fairly simple example, based on your code, that inserts a string and then
walks the list. Error checking should be added...
bash-2.05b$ cat list.c
#include <stdio.h>
#include <libxml/list.h>
int
walker(const char *data, const void *user)
{
printf("data: %s\n", data);
return (1);
}
int
main(void)
{
xmlListPtr list;
list = xmlListCreate(NULL, NULL);
if ((xmlListInsert (list, (void *) "test") ) ) {
printf ("error\n");
}
xmlListWalk(list, (xmlListWalker)walker, NULL);
return (0);
}
Compile:
cc `xml2-config --cflags --libs` -o list list.c
Test:
bash-2.05b$ ./list
data: test
bash-2.05b$
Gary
--
Gary Pennington
Solaris Kernel Development,
Sun Microsystems
Gary Pennington sun com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]