zoukankan      html  css  js  c++  java
  • Libxml2中使用xpath解析xml问题

    //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
    }
  • 相关阅读:
    book pile SGU
    Inversions SGU
    蒟蒻LQL的博客
    控制台注入DLL代码
    Windows消息类型
    windows编程中的数据类型
    单链表的创建与遍历
    定义函数指针
    启动外部程序
    dll共享段中一些需要注意的问题
  • 原文地址:https://www.cnblogs.com/pipizhu/p/2006817.html
Copyright © 2011-2022 走看看