libxml2で属性(xsi:nil="true")を取得する
xmlNodePtr cur = ...;
/*****
(1)
*/
xmlChar *prop = xmlGetProp(cur, (const xmlChar *) "nil");
// xmlChar *prop = xmlGetNsProp(cur, (const xmlChar *) "nil", (const xmlChar *) "http://www.w3.org/2001/XMLSchema-instance");
NSLog(@"prop : %p", prop);
if (prop != NULL) {
NSString *value = [NSString stringWithCString:(char*)prop encoding:NSUTF8StringEncoding];
NSLog(@"value >>>>>>>>>> %@", value);
xmlFree(prop);
}
/*****
(2) = (1)
*/
const xmlChar *ret=NULL;
xmlAttrPtr prop = cur->properties;
while( prop ) {
if( xmlStrEqual( prop->name, (const xmlChar *) "xsi:nil" ) == 0 ) {
ret = prop->name;
break;
}
prop = prop->next;
}
if (ret != NULL) {
NSString *value = [NSString stringWithCString:(char*)ret encoding:NSUTF8StringEncoding];
NSLog(@"value >>>>>>>>>> %@", value);
xmlFree(ret);
}