[xml] Help with xml attributes.



Hello I just wrote a little pieve of code to start reading xml
attributes in. I have managed to read in attribute values, however I
would like to be able to get the name of the attribute as well.

Can someone point me to an example? Or provide a suggestion ...

My code is below ...

Cheers,

Jim

int     numattrs = xmlTextReaderAttributeCount(reader);

if( (numattrs%2)!=0 ) 
{
        printf("Error: every attr should have a value!\n");
}
                        
for(int j=0; j < numattrs; j+=1)
{
        const xmlChar * attrname;
        
        /*HERE IS WHERE I NEED THE NAME :-) */
        attrname= "name";//xmlTextReaderGetAttributeNo(reader, j);

        const xmlChar * attrval;
        attrval=xmlTextReaderGetAttributeNo(reader,j);                  
        printf(" %s = %s ", attrname, attrval);
}




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