title: Parsing HTML with XPath in Objective-C
body: <p>Hey guys, I'm trying to parse HTML with XPath from <a href="http://lib.harvard.edu/libraries/hours.html" rel="nofollow">http://lib.harvard.edu/libraries/hours.html</a> in Objective-C for an application that shows the operating hours for each day of the week at each of the 50 libraries listed on the website. I found code to facilitate XPath parsing of HTML in Objective-C at cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html, but I'm still a little confused about how I should go about obtaining the hours for each day for each library. The relevant method to use seems to be</p>
  
  <pre><code>NSArray *PerformHTMLXPathQuery(NSData *document, NSString *query)
  </code></pre>
  
  <p>and my code so far is</p>
  
  <pre><code>NSURL *urlPath = [NSURL URLWithString:@"http://lib.harvard.edu/libraries/hours.html"];
  NSArray *array = PerformHTMLXPathQuery([NSData dataWithContentsOfURL:urlPath], NSString *query);
  </code></pre>
  
  <p>but, since I've never used XPath before, I'm not sure what string I should use in the second parameter of the method. Does anyone have any ideas?</p>
  
  <p>Also, I'm not quite sure what to do with the array that gets returned by PerformHTMLXPathQuery(). I feel like cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html gives a pretty good explanation, it's just that I've never used XPath before so it doesn't make much sense to me at this point. So, to summarize, as long as my code so far is correct, I want to know what to use for the second parameter in the PerformHTMLXPathQuery() method and how to extract the relevant data from the array it returns. Any help would be much appreciated!</p>