2013-08-23 49 views
0

使用這是正確的XPath // P [ID =「Q」]爲「誰陷害法」 即使這Hpple給了我一個null值是我的Xpath正確與Hpple

<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 [email protected]"//p[id='Q']"; 
    NSArray *tutorialsNodes = [StuffParser searchWithXPathQuery:XpathQ]; 
    NSString *[email protected]""; 
    for (TFHppleElement *element in tutorialsNodes) { 
     QS=[element content]; 
     NSLog(@"%@",[element content]); 

    } 

回答

0

因爲「ID」是屬性你應該@使用它,即//p[@id='Q']