I have this code:
<code>
<div id="accordion" class="ui-accordion ui-widget ui-helper-reset" role="tablist">
<h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-state-focus" role="tab"
aria-expanded="false" tabindex="0">
<a><img class="img" alt="NOS" src="/images/small-nos.png"><span>10:00</span>NOS</a></h3>
<div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" role="tabpanel"
style="display: none; ">
<a href="/news1276" target="_blank">Today's headlines</a>
<h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-state-focus" role="tab"
aria-expanded="false" tabindex="0">
<a><img class="img" alt="SBS" src="/images/small-sbs.png"><span>11:00</span>SBS</a></h3>
<div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" role="tabpanel"
style="display: none; ">
<a href="/news1278" target="_blank">Nieuws</a>
</div>
</div>
</code>
What I am doing is the following:
// parse the html into a DOMDocument
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$accordions = $xpath->query("//div[@id='accordion']/div");
// Iterate events
for($i = 0; $i < ($accordions->length); $i++) {
// The node
$event = $accordions->item($i);
// The urls of the node
$urls = $xpath->evaluate('.//a/@href', $event);
if ($urls->length > 0)
{
$result[$i] .= $urls->item(0)->value;
}
}
which gets me the urls I want. I am however also trying to get all the elements in the <h3>
's, I'd like to retrieve the image and all span's within those h3's as it iterates but this is giving me headaches as I have tried all sorts of things. Can anyone please shed some light?
Thanks,
Al