Hi all,
I am working on a parser to get data from xml file,I am using libxml2 to extract data.I am a not able to get the attributes from nodes,I am using nb_attributes to get the count of the attributes,Can some one help me out
Thank You
Hi all,
I am working on a parser to get data from xml file,I am using libxml2 to extract data.I am a not able to get the attributes from nodes,I am using nb_attributes to get the count of the attributes,Can some one help me out
Thank You
Try something like:
xmlNodePtr node; // Some node
NSMutableArray *attributes = [NSMutableArray array];
for(xmlAttrPtr attribute = node->properties; attribute != NULL; attribute = attribute->next){
xmlChar *content = xmlNodeListGetString(node->doc, node->children, YES);
[attributes addObject:[NSString stringWithUTF8String:content]];
xmlFree(content);
}
I think joostk meant attribute->children, giving something like this:
xmlAttr* attribute = node->properties;
while(attribute && attribute->name && attribute->children)
{
xmlChar* value = xmlNodeListGetString(node->doc, attribute->children, 1);
//do something with value
xmlFree(value);
attribute = attribute->next;
}
See if that works for you.