Reputation: 105
<a id="yui_3_4_1_1_1329966665861_8510" class="buy-as-gift-link"
data-bntrack="buyasgift" href="#purchase=9780345527721"></a>
need to extract "#purchase=9780345527721" from this element using Xpath
this is what i have done till now :
$nodelist_nook = trim($xpath_nook->query("//a[@class='buy-as-gift-link']")->item(0)->nodeValue);
Upvotes: 1
Views: 92
Reputation: 243459
Use:
//a[@id='yui_3_4_1_1_1329966665861_8510']/@href
This XPath expression selects all href
attributes of all a
elements that have an id
attribute with string value "yui_3_4_1_1_1329966665861_8510"
.
In case you want to get not the attribute node (we hope that no two elements exist with the same value for id
) but just its string value, this can be obtained as result of evaluating the following XPath expression:
string(//a[@id='yui_3_4_1_1_1329966665861_8510']/@href)
Upvotes: 3