ÈçºÎʹÓÃObjective C½âÎöHTMLºÍXML
ʹÓÃObjective-C½âÎöHTML»òÕßXML£¬ÏµÍ³×Ô´øÓÐÁ½ÖÖ·½Ê½Ò»¸öÊÇͨ¹ýlibxml£¬Ò»¸öÊÇͨ¹ýNSXMLParser¡£²»¹ýÕâÁ½ÖÖ·½Ê½¶¼ÐèÒª×Ô¼ºÐ´ºÜ¶à±àÂëÀ´´¦ÀíץȡÏÂÀ´µÄÄÚÈÝ£¬¶øÇÒ²»ÊǺÜÖ±¹Û¡£
ÓÐÒ»¸ö±È½ÏºÃµÄÀà¿âhpple£¬ËüÊÇÒ»¸öÇáÁ¿¼¶µÄ°ü×°¿ò¼Ü£¬¿ÉÒԺܺõĽâ¾öÕâ¸öÎÊÌâ¡£ËüÊÇÓÃXPathÀ´¶¨Î»ºÍ½âÎöHTML»òÕßXML¡£
°²×°²½Ö裺
-¼ÓÈë libxml2 µ½ÄãµÄÏîÄ¿ÖÐ
Menu Project->Edit Project Settings
ËÑË÷ “Header Search Paths”
Ìí¼ÓÐ嵀 search path “${SDKROOT}/usr/include/libxml2″
Enable recursive option
-¼ÓÈë libxml2 library µ½ÄãµÄÏîÄ¿
Menu Project->Edit Project Settings
ËÑË÷ “Other Linker Flags”
Ìí¼ÓÐ嵀 search flag “-lxml2″
-½«ÏÂÃæhppleµÄÔ´´úÂë¼ÓÈëµ½ÄãµÄÏîÄ¿ÖÐ:
HTFpple.h
HTFpple.m
HTFppleElement.h
HTFppleElement.m
XPathQuery.h
XPathQuery.m
-XPathѧϰµØÖ·http://www.w3schools.com/XPath/default.asp
ʾÀý´úÂ룺
#import "TFHpple.h"
NSData *data = [[NSData alloc] initWithContentsOfFile:@"example.html"];
// Create parser
xpathParser = [[TFHpple alloc] initWithHTMLData:data];
//Get all the cells of the 2nd row of the 3rd table
NSArray *elements = [xpathParser search:@"//table[3]/tr[2]/td"];
// Access the first cell
TFHppleElement *element = [elements objectAtIndex:0];
// Get the text within the cell tag
NSString *content = [element content];
[xpathParser release];
[data release];
ÁíÍ⣬»¹ÓÐÒ»¸öÀàËƵĽâ¾ö·½°¸¿ÉÒԲο¼
ElementParser http://github.com/Objective3/ElementParser
Ïà¹ØÎĵµ£º
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Page</title>
</head>
<body>
<table border="1px">
......
´¿Îı¾»¹ÊÇHTML?
---ÄÄÒ»ÖÖÓʼþÀàÐ͸üÊʺÏÄ㣿
ÒýÑÔ
Èç¹ûÄãÕý×¼±¸Æô¶¯Ò»ÏîÓʼþÓªÏú¼Æ»®£¬µ«²»È·¶¨ÊǸÃÓÃͼÎIJ¢Ã¯µÄHTMLÓʼþÀ´ÌáÉýÓʼþµÄÊÓ¾õÌåÑ飬»¹ÊÇÓô¿Îı¾µÄÓʼþÀ´Ìá¸ßÓʼþµÄËÍ´ïÂÊ£¨²¢½ÚÊ¡×ÊÔ´£©£¬Comm100½«Í¨¹ý±¾ÎÄΪÄãÁоÙÕâÁ½ÖÖÓʼþÀàÐ͸÷×ÔµÄÓÅÁÓÊÆ£¬²¢½ÌÄãÈçºÎͨ¹ýÄ£°åÀàÐͺÍÏÔʾЧ¹ûÀ´ÓÅ»¯ÄãµÄÓʼþÓªÏú¼Æ»®¡ ......
´´½¨Ð½ø³Ì£ºforkº¯Êý
1.1.1. forkº¯Êý¸Éʲô£¿
#include <sys/types.h>
#include <unistd.h>
pid_t fork(void);
‘fork()’º¯ÊýÓÃÓÚ´ÓÒÑ´æÔÚ½ø³ÌÖд´½¨Ò»¸öнø³Ì¡£Ð½ø³Ì³ÆΪ×Ó½ ......
ÔÚc++ primeÊéÖп´µ½¹ý£¬ÔÚDLLºÍlibÖп´µ½¹ý£¬µ«ÊÇÿ´Î¿´¹ý¾Í²»ÇóÉõ½âµØһɨ¶ø¹ý¡£ÐÄÀïÖªµÀÓÐextern cÕâ¸öÓï¾ä£¬È´²»ÖªµÀ¸ÃÓÃÔÚÄÄÀÓÖÄÜÆðµ½Ê²Ã´×÷Óᣰ¦£¬ÏëÏë×Ô¼ºÒ²ËãÊÇд¹ý²»ÉÙCODEµÄÈËÁË£¬¿ÉÕâÖÖÑÛ¸ßÊֵ͵Ä벡ȴ´Óû¸Ä±ä¹ý¡£½ñÌìͻȻÏëÆðexternÕâ¸ö¹Ø¼ü×Ö£¬Ëì¾ö¶¨²»ÄÜÔÙÕâôÀË ......
HTML ÊÇ Web ͳһÓïÑÔ£¬ÕâЩÈÝÄÉÔÚ¼âÀ¨ºÅÀïµÄ¼òµ¥±êÇ©£¬¹¹³ÉÁËÈç½ñµÄ Web¡£1991 Ä꣬Tim Berners-Lee
±àдÁËÒ»·Ý½Ð×ö “HTML ±êÇ©”µÄÎĵµ£¬ÀïÃæ°üº¬ÁË´óÔ¼20¸öÓÃÀ´±ê¼ÇÍøÒ³µÄ HTML ±êÇ©¡£ËûÖ±½Ó½èÓà SGML
µÄ±ê¼Ç¸ñʽ£¬Ò²¾ÍÊǺóÀ´ÎÒÃÇ¿´µ½µÄ HTML ±ê¼ÇµÄ¸ñʽ¡£±¾ÎĽ²ÊöÁË HTML ÕâÃÅ Web ±ê¼ÇÓïÑԵķ¢Õ¹¼òÊ·¡£
......