First, the good brother package of parsing files and https://github.com/topfunky/hpple downloaded folder into the project
Add Libxml2.dylib Frame
Add/USR/INCLUDE/LIBXML2 in Header Search Paths
Introduction of header File YXHTML.h
Get Data
NSData *data = [yxhtml htmldata:@ "http://www.cnblogs.com/YouXianMing/"];
Creating a parser
yxhtml *html = [[Yxhtml alloc] initwithhtmldata:data];
Judging can be resolved
if (html.isaccess = = YES)
{
Get all the a nodes in the data
[HTML serachwithnode:@ "//a" each:^ (BOOL sucess, tfhppleelement *element)
{
if (sucess)
{
Gets the node in all the A nodes attribute the value of the HREF to the node in http://www.cnblogs.com/YouXianMing/
if ([element.attributes[@ "href"] \
isequaltostring:@ "http://www.cnblogs.com/YouXianMing/"])
{
Get the contents of this node
NSLog (@ "%@", Element.text);
}
}
}];
}
Else
{
NSLog (@ "Cannot parse");
}
If you forget to view the alternate->demo-> parsing HTML
For details, please http://www.cnblogs.com/YouXianMing/p/3731866.html thank you for sharing ~