2
I’m trying to get the data from a DIV that contains the following structure:
<div class="item" style="height:273px">
<a href="/arapiraca/anuncios/detalhes/159695-honda-cg-150-2008">
<img alt="" src="/i.php?w=148&h=119&f=3,0|4,0&src=uploads/anunciosfotos/2014/04/858a6126588bdace8bc0f144f900d097.jpg"></img>
<img src="/img/icone-novo.png" alt="" style="position: absolute; z-index: 20; width: 60px; height: 60px; right: -5px; top: -10px; border: 0"></img>
<strong class="nome" style="font-weight:normal">
HONDA CG 150 2008 TITAN - KS GASOLINA
</strong>
<strong class="valor">
R$ 4.500,00
</strong>
<span class="vendedor">
<span>
<img alt="" src="/i.php?w=148&h=60&src=uploads/clientes/2659aa7030bac6f245852b948187188a.jpg"></img>
</span>
</span>
</a>
<input class="comparacao" type="checkbox" name="comparacao[159695]" value="159695"></input>
$dom = new DOMDocument();
@$dom->loadHTML($content);
$xpath = new DOMXPath($dom);
$classname = "item";
$nodes = $xpath->query("//*[@class='" . $classname . "']");
foreach ($nodes as $node) {
echo $node->nodeValue . " <br> ";
}
With the above code, I can get only the following result:
HONDA CG 150 2008 TITAN - KS GASOLINA R$ 4.500,00
I need to also get the tags to.
you want all the
<img><span><strong>
inside<a>
?– rray
I want to get what’s here <a href="/Arapiraca/anuncios/detalhes/159695-Honda-cg-150-2008">
– Marcelo de Andrade
$node->attributes
?– Beterraba
@Beet;
Catchable fatal error: Object of class DOMNamedNodeMap could not be converted to string
– Marcelo de Andrade