How to use xmlChar ** atts in startElementSAXFunc to get attribute name and value?

In libxml2, how do I use atts in startElementSAXFunc to get attribute name and value? The documentation says that atts is an “An array of name/value attributes pairs, NULL terminated”. But its use is not very clear.

Are attribute name and value stored in contiguous memory locations?

Also, why doesn’t it use xmlAttr instead of xmlChar ** ?

1 Like
int i = 0;
while(atts && atts[i]!=NULL){
    printf("attr name = %s", atts[i]);
    printf("attr value = %s", atts[i+1]);
    i+=2;
}

This works

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.