Last active
December 26, 2015 04:49
-
-
Save mtsd/7096415 to your computer and use it in GitHub Desktop.
libxml2で属性(xsi:nil="true")を取得する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment