iosxpathhpple

Is my Xpath Correct for using with Hpple


Is this the correct Xpath //p[id='Q'] for "Who Framed the Law" Even with this in Hpple gives me a value of null

<html>
    <p id="Q">Who Framed the Law?</p>
    <p id="A1">Brian</p>
    <p id="A2">Ted</p>
    <p id="A3">Ki</p>
    <p id="A4">Shane Pizza</p>
</html>

    NSString *XpathQ =@"//p[id='Q']";
    NSArray *tutorialsNodes = [StuffParser searchWithXPathQuery:XpathQ];
    NSString *QS=@"";
    for (TFHppleElement *element in tutorialsNodes) {
        QS=[element content];
        NSLog(@"%@",[element content]);

    }

Solution

  • Since "id" is attribute you should use it with @, i.e. //p[@id='Q']