My favorites
▼
|
Sign in
touchcode
Repository of iPhone and iPod Touch source code.
Project Home
Export to GitHub
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
53
attachment: WRTouchParser.m
(1.2 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// WRTouchParser.m
// WordReference
//
// Created by Harold Leboulanger on 29/03/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "WRTouchParser.h"
#import "WRTranslation.h"
@implementation WRTouchParser
- (id)init
{
if (![super init])
return nil;
translation = [[WRTranslation alloc] init];
return self;
}
- (void)dealloc
{
[translation release];
[super dealloc];
}
- (BOOL)parseData:(NSData *)d xpath:(NSString *)s
{
NSError *error;
NSError *errorT;
CXMLDocument *parserT = [[CXMLDocument alloc] initWithData:d
options:9
error:&error];
NSXMLDocument *parser = [[NSXMLDocument alloc] initWithData:d options:9 error:&error];
// We need to know if we have to parse this page or not !
NSArray *res = [parser nodesForXPath:@"//*[@id=\"noEntryFound\"]" error:nil];
if ([res count] == 1) {
[translation setError:@"No translation found!"];
[parser release]; // release also the res array
return NO;
}
// Ok let's go for the parsing
res = [parser nodesForXPath:s error:&error];
NSArray *resT = [parserT nodesForXPath:s error:&errorT];
// Result
NSLog(@"res = %@", res);
NSLog(@"resT = %@", resT);
return YES;
}
- (WRTranslation *)translation
{
return translation;
}
@end
Powered by
Google Project Hosting