Re: [xml] sax + startElement



Hi Jovan,
          None of the elements in the XML File you specified have
attributes. So naturally you will get NULL pointer for atts structure.
Thanks & Regds.,
Jaya Kumar

-----Original Message-----
From: xml-bounces gnome org [mailto:xml-bounces gnome org] On Behalf Of
Jovan Kostovski
Sent: Friday, February 09, 2007 12:12 AM
To: xml gnome org
Subject: [xml] sax + startElement

Hi,

I'm writing a sax parser in c. So far everything looked good
till I needed to extract the element values (attributes).

I want to extract the element atributes and to fill in some structures in
my program.

My startElement handler which I wrote for testing
 is a copy of code from xmllinit.c

void startElement(void * ctx, const xmlChar * name, const xmlChar ** atts) {
        int i;

fprintf(stdout, "SAX.startElement(%s", (char *) name);
    if (atts != NULL) {
        for (i = 0;(atts[i] != NULL);i++) {
            fprintf(stdout, ", %s='", atts[i++]);
            if (atts[i] != NULL)
                fprintf(stdout, "%s'", atts[i]);
        }
    }
}

The problem is that I always get NULL pointer for atts structure. Any Ideas?

I'm testing the parser with small xml file:

<?xml version="1.0"?>
<array>
  <number>0</number>
  <number>1</number>
  <number>42</number>
</array>

BR, Jovan
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml





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