Search code examples
objective-cxmlxpathhpple

Hpple - Reading a tag with an attribute


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?


Solution

  • 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.