//hack to remove xmlns => avoid xpath search not works
//如果节点xml节点含有xmlns,这个时候用xpath是匹配不出节点内容的,只好删掉了,找这个原因不容易啊 - -|||
xmlStr = [xmlStr stringByReplacingOccurrencesOfString:@"xmlns" withString:@"noNSxml"];
NSMutableArray* contents = [NSMutableArray array];
NSError* error = nil;
DDXMLDocument* xmlDoc = [[DDXMLDocument alloc] initWithXMLString:xmlStr options:0 error:&error];
if (error) {
NSLog(@"%@",[error localizedDescription]);
return nil;
}
NSArray* resultNodes = nil;
resultNodes = [xmlDoc nodesForXPath:@"//audio | //text | //image | //img" error:&error];
if (error) {
NSLog(@"%@",[error localizedDescription]);
return nil;
}
for(DDXMLElement* resultElement in resultNodes)
{
NSString* name = [resultElement name];
//audio , text or other media type
NSString* fileName = [[resultElement attributeForName:@"src"] stringValue];
// 0.txt
}