xxxmmllll

#import <Foundation/Foundation.h>


@interface FAQIndexOperation : NSOperation{

    NSURL *_targetURL;

    id _target;

    SEL _action;

}

@property(retain) NSURL *targetURL;

@property(retain) id target;

//@property(retain) SEL action;


-(id)initWithURL:(NSURL *)theURL target:(id)theTarget action:(SEL)theAction;


@end



@implementation FAQIndexOperation

@synthesize target,targetURL;


-(id)initWithURL:(NSURL *)theURL target:(id)theTarget action:(SEL)theAction

{

    self = [super init];

    if(self){

        targetURL = [theURL retain];

        target = theTarget;

        _action = theAction;

    }

    return self;

}


- (void)dealloc

{

    [targetURL release],targetURL=nil;

    [target release],target = nil;

    [super dealloc];

}


- (void)main

{

    

    CXMLDocument *document = [[CXMLDocumentalloc]initWithContentsOfURL:targetURL encoding:NSUTF8StringEncodingoptions:0 error:nil];

    

    FAQIndexParser *parser = [[FAQIndexParseralloc]initwithDocument:document];

    NSMutableArray *faqList = [parser parserFAQIndexPage];

    

    

    [target performSelectorOnMainThread:_action withObject:faqListwaitUntilDone:YES];

//    NSLog(@"done");

    [parser release];

}

@end



//  FAQIndexParser.h

//  Hq88Project

//

//  Created by hq88 on 12-9-5.

//  Copyright (c) 2012年 hq88.com. All rights reserved.

//


#import <Foundation/Foundation.h>

#import "TouchXML.h"


@interface FAQIndexParser : NSObject

{

    CXMLDocument *_document;

    NSString *allpage;

//    NSMutableArray *_journalList;

}


@property (nonatomic,retain) CXMLDocument *document;

@property (nonatomic,retain) NSString *allpage;

//@property (nonatomic,retain) NSMutableArray *journalList;


-(id)initwithDocument:(CXMLDocument *)document;



-(NSMutableArray *)parserFAQIndexPage;

@end



//  FAQIndexParser.m

//  Hq88Project

//

//  Created by hq88 on 12-9-5.

//  Copyright (c) 2012年 hq88.com. All rights reserved.

//


#import "FAQIndexParser.h"

#import "TbFAQ.h"


@implementation FAQIndexParser

@synthesize document;

@synthesize allpage;

//@synthesize journalList = _journalList;




-(NSMutableArray *)parserFAQIndexPage

{

    NSMutableArray *faqArray = [[[NSMutableArray alloc]init]autorelease];

    NSMutableArray *dataList = [[[NSMutableArray alloc]init]autorelease];

    

//    NSLog(@"********%@",self.document);

    

    CXMLElement *root = [self.document rootElement];

    NSArray *items = [root children];

    

    for (CXMLElement *element in items) {

        if ([element isKindOfClass:[CXMLElement class]]) {

            if ([[element name]isEqualToString:@"courses"]) {

                self.allpage = [[element attributeForName:@"allpage"]stringValue];

                for (int i = 0; i < [element childCount]; i++) {

                    if ([[element childAtIndex:i]isKindOfClass:[CXMLElement class]]) {

                        TbFAQ *faq = [[TbFAQ alloc]init];

                        CXMLElement *child = [[element children]objectAtIndex:i];

                        

                        faq.faqID = [[child attributeForName:@"id"]stringValue];

                        faq.faqName = [[child attributeForName:@"name"]stringValue];

                        faq.faqGrade = [[child attributeForName:@"grade"]stringValue];

                        faq.faqImageURL = [[childattributeForName:@"imgurl"]stringValue];

                        faq.faqLiveURL = [[child attributeForName:@"liveurl"]stringValue];

                        faq.faqLecturer = [[childattributeForName:@"lecturer"]stringValue];

                        for (int j = 0; j < [child childCount]; j++) {

                            if ([[child childAtIndex:j]isKindOfClass:[CXMLElement class]]) {

                                CXMLElement *summary = [[child children]objectAtIndex:j];

                                faq.faqSummary = [[summarystringValue]stringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceAndNewlineCharacterSet]];

//                                NSLog(@"%@",faq.faqSummary);

                            }

                        }

                        

                        [faqArray addObject:faq];

                        [faq release];

                    }

                }

            }

        }

    }

    NSLog(@"self.allpage%@",self.allpage);

    [dataList addObject:faqArray];

    [dataList addObject:self.allpage];

    

    return dataList;

}


-(id)initwithDocument:(CXMLDocument *)thedocument

{

    self = [super init];

    if (self) {

        document = thedocument;

    }

    return self;

}


-(void)dealloc

{

    [document release],document = nil;

    [allpage release],allpage = nil;

//    [self.journalList release],self.journalList = nil;

    [super dealloc];

}

@end


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值