- HTFpple.h
- HTFpple.m
- HTFppleElement.h
- HTFppleElement.m
- XPathQuery.h
- XPathQuery.m
-Add libxml2 includes to your project
- Menu Project->Edit Project Settings
- Search for setting "Header Search Paths"
- Add a new search path "${SDKROOT}/usr/include/libxml2"
- Enable recursive option
-Add libxml2 library to to your project
- Menu Project->Edit Project Settings
- Search for setting "Other Linker Flags"
- Add a new search flag "-lxml2"
- (void)viewDidLoad {
[superviewDidLoad];
NSString *htmlWillInsert = [[NSStringstringWithContentsOfURL:
[NSURLURLWithString:@"http://web2.kwangju.ac.kr/~gjh/sub03/sub03.php"]
encoding:-2147481280error:nil]
stringByReplacingOccurrencesOfString:@"<br>"withString:@" "];
NSData *htmlData = [htmlWillInsert dataUsingEncoding:NSUnicodeStringEncoding];
TFHpple *xpathParser = [[TFHpplealloc] initWithHTMLData:htmlData];
NSArray *elements = [xpathParser search:@"//table[@width=\"679\"]//td[@valign=\"top\"]"];
NSLog(@"%@",elements);
for(int i=0;i<[elements count];i++)
{
TFHppleElement *element = [elements objectAtIndex:i];
NSString *titleOfAlips = [element content];
NSLog(@"%@",titleOfAlips);
}
}
위 코드에서 사용된 xPath의 사용법 : http://www.w3schools.com/XPath/xpath_syntax.asp
'프로그래밍 > Objective C' 카테고리의 다른 글
APPLE :: 네비게이션바 숨기기 (0) | 2010.11.14 |
---|---|
APPLE :: SelectString (문장 잘라내기) (0) | 2010.11.10 |
APPLE :: Loading Screen(시작 로딩 화면) (0) | 2010.11.10 |
APPLE :: XML 파싱 (0) | 2010.11.10 |
APPLE :: IPhone On OpenCV (0) | 2010.11.03 |