0

I'm trying to parse a XML,

 <entry>
 <title type="html"><![CDATA[TITLE]]></title>
 </entry>

Using Hpple, I'm trying to read the

 NSArray *array = [xpathParser searchWithXPathQuery:@"//entry/title[@type='html']"];

But the returned value is null. What I'm doing wrong?

1 Answers1

0

As hpple is a wrapper over XPathQuery, you might want to check it this answer

tl;dr Try adding /text() to your XPath query.

Also it looks like Hpple's author uses a different function call to search by XPath in his Unit Test for hpple; for example NSArray * a = [doc search:@"//a[@class='sponsor']"];, perhaps its worth to give that a shot.

Community
  • 1
  • 1
Sjaak Trekhaak
  • 4,906
  • 30
  • 39
  • Thanks for the comment, but now, instead showing _"(null)"_ in the NSLog, the application crash: _"index 0 beyond bounds for empty array"_; –  Mar 13 '12 at 03:06
  • Am I doing this right: _searchWithXPathQuery:@"//entry/title[@type='html']/text()"_? –  Mar 13 '12 at 03:10
  • For as far as the XPath is concerned, that looks alright. I've never used Hpple before so I wouldn't know about that however... – Sjaak Trekhaak Mar 13 '12 at 08:09