Reputation: 23
I'm looking to extract some data of a website using XPath with PHP. Here is an example of page: http://www.education.gouv.fr/annuaire/49-maine-et-loire/cholet/lycee/lycee-polyvalent-europe-robert-schuman.html
I managed to get different informations I was looking for except one. The href attribute of the "Site Internet" link (the third link of three in the middle of the page).
The Xpath of this node is :
//*[@id="contenu"]/div[1]/div[5]/div[1]/div[5]/ul/li[3]/a
And I know that to get the value of an attribute we need to add @attribute, so I tried:
//*[@id="contenu"]/div[1]/div[5]/div[1]/div[5]/ul/li[3]/a@href
But it doesn't work, it's just showing me the text "Site internet". Can you help me please ? Thanks.
Upvotes: 0
Views: 63
Reputation: 66
To get the href value of a link, it's a/@href
.
So your query would then be:
//*[@id="contenu"]/div[1]/div[5]/div[1]/div[5]/ul/li[3]/a/@href
Upvotes: 1