Reputation: 17
Hey guys so i am trying to get to the link in the code below however the only div with a name is inside the href. I know how to get to the href if it was inside the div but not this way around. Can anyone help?
<div>
<a href="/economic-research/blog/EconomicPublications/algeria-country-report-mar17.pdf">
<div class="CountryRiskReportLink">
Algeria Country Report
</div></a>
</div>
Upvotes: 0
Views: 320
Reputation: 54984
In simple-html-dom you would use parent()
:
$div = $doc->find('.CountryRiskReportLink', 0);
echo $div->parent()->href;
Upvotes: 1
Reputation: 2249
Yes, You can get the value of href attribute without JQuery. Here is the simple snippet. Try this,
$a = new SimpleXMLElement("<a href='/economic-research/blog/EconomicPublications/algeria-country-report-mar17.pdf'>
<div class='CountryRiskReportLink'>
Algeria Country Report
</div>
</a>");
echo $a['href']; // will echo /economic-research/blog/EconomicPublications/algeria-country-report-mar17.pdf
die();
Hope this will help you!
Upvotes: 0