Began
- 不逼逼,直接代碼
NSMutableString *str = [[NSMutableString alloc] init];
NSString *protocolPath = [[NSBundle mainBundle] pathForResource:_textFiel ofType:@"txt"];
xmlDocPtr doc = xmlReadFile([protocolPath UTF8String], NULL, XML_PARSE_RECOVER);
if (!doc)
{
return nil;
}
xmlNodePtr root = xmlDocGetRootElement(doc);
if (root)
{
for (xmlNodePtr curNode = root->children; NULL != curNode; curNode = curNode->next)
{
if(strcmp((char *)curNode->name, "string") == 0)
{
[str appendString:[NSString stringWithCString:(const char*)xmlNodeGetContent(curNode) encoding:NSUTF8StringEncoding]];
[str appendString:@"\n"];
}
}
}
xmlFreeDoc(doc);
return str;
End