Question

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]);

    }
Was it helpful?

Solution

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

OTHER TIPS

You should use an expression like //p[@id='Q'] .See xpath syntax

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top