zoukankan      html  css  js  c++  java
  • KissXML类库的使用方法

    1、添加附件里面的KissXML到工程

    2、加入libxml2.dylib 到Frameworks

    3、修改工程信息,右击Targets下工程名选“Get Info”,进入修改Header Search Paths值为:/usr/include/libxml2,如附件图

    附件2为Demo,可运行。

    19_2069_7c9ff273f3d8ad3.png

    NSString *content = [NSString stringWithContentsOfURL: url  
                                                     encoding:NSUTF8StringEncoding
                                                        error:&error];
        [string release];
        [self parsedDataFromString:content];
    }  
    
    
    -(void)parsedDataFromString:(NSString *)str{
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
        DDXMLDocument *doc = [[DDXMLDocument alloc] initWithXMLString:str options:0 error:nil];
    
    /////解析
        NSArray *items = [doc nodesForXPath:kXML error:nil];
        
        for (DDXMLElement *obj in items) {
            xmlData *data = [[xmlData alloc] init];
            
            DDXMLElement *aUser = [obj elementForName:KUSER];
            if(aUser)
                data.user = aUser.stringValue;
            DDXMLElement *aTitle = [obj elementForName:KTITLE];
            if(aTitle)
                data.title = aTitle.stringValue;
            DDXMLElement *content = [obj elementForName:KCONTENT];
            if(content)
                data.content = content.stringValue;
            NSDictionary *XmlDictionary;
            XmlDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                             data.user,@"kUsers",
                             data.title,@"kTitles",
                             data.content,@"kContents",
                             nil];
            [self performSelectorInBackground:@selector(parsedXml:) withObject:XmlDictionary];
            [data release];
        }
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
        [doc release];
    }
  • 相关阅读:
    Linux thread 泄露问题
    QQ通讯原理
    小谈Onlinegame服务器端设计
    Linux 如何打开端口
    linux系统软件更新
    MVC
    wubi+ubuntu
    [转]openfire源码部署~
    Apache开源项目分类列表[转]
    [转]java.util.MissingResourceException: Can't find bundle for base name
  • 原文地址:https://www.cnblogs.com/lingzhao/p/3408598.html
Copyright © 2011-2022 走看看