Was following this Simple libxml2 HTML parsing example, using Objective-c, Xcode, and HTMLparser.h and http://benreeves.co.uk/objective-c-hmtl-parser/
The author notes that there’s something wrong with rawContentsOfNode method.
NSArray *bodytext = [bodyNode findChildTags:@"td"];
for (HTMLNode *inputBody in bodytext) {
//NSLog(@"%@", [inputBody getAttributeNamed:@"class"]);
NSString *test = rawContentsOfNode(xmlNode *bodytext, htmlDocPtr doc);
}
There doesn’t seem to be any example of using the updated version. and I can’t figure out whats wrong. Any help with fixing this would be great.
The example in the StackOverflow answer won’t even compile because he has just copy-pasted the note in the original example.
This:
is part of a function prototype not a function call. It’s a C function that requires and
xmlNodeand ahtmlDocPtras parameters. Looking at the interface of HTMLNode, we see that the prototype given in the comment is wrong, it should be:There’s no mention in the source code of a function matching the prototype recommended in the blog post. I have no idea what they were talking about, unless it has been removed since the comment was made.
The XML node is a public member of the HTML node, so you could do:
But the method
rawContentsdoes that anyway so you might as well use it.Note that (again checking the source code) there is an issue in that the content of the node is assumed to be encoded in UTF-8 this may be true, but the default encoding for HTTP is ISO-8859-1 so it may not.