0
I’m trying to download the content of a site, but is giving this Warning:
`Domdocument::loadHTML(): Unexpected end tag : tr in Entity
And it’s spelling out several lines. I’m also not getting the accent fixed.
Someone could help me understand and solve these problems?
$content = http_build_query([
'Local' => 'Adamantina',
'Inicio' => '01/01/2015',
'Final' => '31/12/2015',
]);
$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $content,
]
]);
$contents = utf8_decode(file_get_contents('http://www.ciiagro.sp.gov.br/ciiagroonline/Listagens/BH/LBalancoHidricoLocal.asp', false, $context));
$dom = new DOMDocument();
$dom->loadHTML($contents);
$dom->saveHTML($dom->documentElement);
$xpath = new DomXPath($dom);
$rows = $xpath->query('//table/tr[position()>0]');
foreach ($rows as $row) {
$tds=$row->getElementsByTagName("td");
foreach ($tds as $td) {
print($td->nodeValue);
echo "<br>";
}
}
thus:
$rows = $xpath->query('//table');
$rows2 = $xpath->query('.//tr', $rows);

foreach($rows2 as $row){
 $tds=$row->getElementsByTagName("td"); 
 foreach($tds as $td){
 print ($td->nodeValue);
 echo "<br>";
 }
}
didn’t work– Leonardo Nori
Yeah, that’s not the problem, see if the answer helps the question.
– Inkeliz