1

I'm starting my iPhone programming adventure, with a simple HTML scraping. I'm using the Hpple library to do the job, and I have a question... Suppose I have the following html to parse...

<div>
    <div> A <!-- Comment 1 --></div>
    <div> B </div>
    <div> C <!-- Comment 2 --></div>
</div>

How can I retrieve the commented parts? They don't show up on the objects... I was checking the docs but there's nothing pointing to that direction.. (also googling "hpple comment" doesn't produce the best results...).

thanks in advance.

Nuno Gonçalves
  • 6,202
  • 7
  • 46
  • 66
  • Maybe look at using NSXMLParser? It seems to support comments according to the documentation: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html – nielsbot Mar 08 '13 at 19:00

1 Answers1

1

Comments are not considered part of the content and are stripped out by pretty much all parsers except humans.

Similarly, you can't ask the parser to tell you how many spaces and newlines are between the first two <div> elements.

Ben S
  • 68,394
  • 30
  • 171
  • 212