I am stuck trying to discover a couple of attribute names and values in some common xmls using libxml2 to parse api in an iPhone application. For my project, parsing speed is really important, so I decided to use libxml2 itself instead of using NSXMLParser.
Now, referring to XMLPerformance, which is a sample of the iPhone SDK for parsing test between NSXMLParser and libxml2, I tried to get the attribute detail in one of the XML parser handlers, as shown below, but I don’t know exactly how to detect it.
static void startElementSAX(void *ctx, const xmlChar *localname, const xmlChar *prefix,
const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes,
int nb_defaulted, const xmlChar **attributes)
{
if (nb_attributes > 0)
{
NSMutableDictionary* attributeDict = [NSMutableDictionary dictionaryWithCapacity:(NSUInteger)[NSNumber numberWithInt:nb_attributes]];
for (int i=0; i<nb_attributes; i++)
{
NSString* key = @"";
NSString* val = @"";
[attributeDict setValue:val forKey:key];
}
}
}
I saw the libxml2 document , but I can not. Please help me if you are a great hacker :)