문제

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

    }
도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top