I think I found why you only have 1 attribute (at least it happened to me).
The problem was that I read the attributes for the first node and then the text node. I donβt know why, but the node β properties give me a link to the unreadable part of the memory, so it crashed.
My solution was to check the type of node (element is 1)
I use the reader, therefore:
xmlTextReaderNodeType(reader)==1
All the code you can get from http://www.xmlsoft.org/examples/reader1.c and add this
xmlNodePtr node= xmlTextReaderCurrentNode(reader); if (xmlTextReaderNodeType(reader)==1 && node && node->properties) { xmlAttr* attribute = node->properties; while(attribute && attribute->name && attribute->children) { xmlChar* value = xmlNodeListGetString(node->doc, attribute->children, 1); printf ("Atributo %s: %s\n",attribute->name, value); xmlFree(value); attribute = attribute->next; } }
to line 50.
tiparega
source share