Capture child attribute value using xpath

Asked

Viewed 194 times

1

With xpath I want to get the value of the attribute of href below, however I need to make sure that will be the url present inside the tag li.

    <li class="event">
<span class="mediaCoverageCont">
</span>
<a href="/esportes-futebol/liga-europa-201718-qualificação/1-102-1250545.html" class="24/08/2017 16:45:00">
<span class="imgOuter"><img alt="Dínamo Kiev x Maritimo" src="https://headlines-teams.s3.amazonaws.com/dinamo-de-kiev.png"/></span>
<span class="imgOuter" id="imgOuterRight"><img alt="Dínamo Kiev x Maritimo" src="https://headlines-teams.s3.amazonaws.com/maritimo.png"/></span>
<span class="currentTitle"><h3>Dínamo Kiev x Maritimo</h3></span>
<span class="currentDate"><img src="/s/images/headlines/currentDate.png" border="0" style="margin-right:3px;" align="center"/>24/08/2017 16:45:00</span>
</a>

I am using this code nothing else is returned, someone knows how I can be solving this problem?

Part of the code I’m using:

$link = $xpath->query('//li[@class="event" ]/a[@*]')->item(0);
  • You want to return /sports-football/league-europe-201718-qualification/1-102-1250545.html ?

  • @juniorb2ss yes

  • Get what you need with this code: $link = $xpath->query('//td[@class="team"]/a/@href')->item(0)->nodeValue;`

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.