<?php
/* Just compose the HTML sample */
$html='<html><head></head><body>';
$html.='<table class="grilla"><tbody><tr class="textEncabezadoGrilla" bgcolor="#C0DAF1" align="center">
<th>Juzgado Policía Local</th>
<th>Rol Causa</th>
</tr>
<tr>
<td class="textgrid2">2 JPL PROVIDENCIA</td>
<td class="textgrid2">018092 - 2010</td>
</tr>
<tr>
<td class="textgrid1">OVALLE JPL</td>
<td class="textgrid1">13115 - 2010</td>
</tr>
</tbody></table>
<table class="grilla"><tbody><tr class="textEncabezadoGrilla" bgcolor="#C0DAF1" align="center">
<th>Juzgado Policía Local</th>
<th>Rol Causa</th>
</tr>
<tr>
<td class="textgrid2">2 JPL PROVIDENCIA</td>
<td class="textgrid2">018092 - 2010</td>
</tr>
<tr>
<td class="textgrid1">OVALLE JPL</td>
<td class="textgrid1">13116 - 2011</td>
</tr>
</tbody></table>';
$html.="</body></html>";
$doc=new DOMDocument();
$doc->loadHTML($html);
$xpath=new DOMXPath($doc);
$tds = array();
var_dump($xpath->query('//table[@class="grilla"]/tbody/tr/td/text()'));
$table1 = $xpath->query('//table[@class="grilla"]')->item(0);
$table2 = $xpath->query('//table[@class="grilla"]')->item(1);
foreach($xpath->query('//table[@class="grilla"]') as $key => $td)
{
array_push($tds, $td);
}
print_r($tds);
$ee = array_chunk($tds, 2);
- Output for 8.3.0 - 8.3.4, 8.3.6
- object(DOMNodeList)#11 (1) {
["length"]=>
int(8)
}
Array
(
[0] => DOMElement Object
(
[schemaTypeInfo] =>
[tagName] => table
[className] => grilla
[id] =>
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] =>
[nextElementSibling] => (object value omitted)
[nodeName] => table
[nodeValue] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
[nodeType] => 1
[parentNode] => (object value omitted)
[parentElement] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] => (object value omitted)
[attributes] => (object value omitted)
[isConnected] => 1
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
)
[1] => DOMElement Object
(
[schemaTypeInfo] =>
[tagName] => table
[className] => grilla
[id] =>
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] => (object value omitted)
[nextElementSibling] =>
[nodeName] => table
[nodeValue] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
[nodeType] => 1
[parentNode] => (object value omitted)
[parentElement] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => (object value omitted)
[nextSibling] =>
[attributes] => (object value omitted)
[isConnected] => 1
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
)
)
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
object(DOMNodeList)#11 (1) {
["length"]=>
int(8)
}
Array
(
[0] => DOMElement Object
(
[schemaTypeInfo] =>
[tagName] => table
[className] => grilla
[id] =>
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] =>
[nextElementSibling] => (object value omitted)
[nodeName] => table
[nodeValue] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
[nodeType] => 1
[parentNode] => (object value omitted)
[parentElement] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] => (object value omitted)
[attributes] => (object value omitted)
[isConnected] => 1
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
)
[1] => DOMElement Object
(
[schemaTypeInfo] =>
[tagName] => table
[className] => grilla
[id] =>
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] => (object value omitted)
[nextElementSibling] =>
[nodeName] => table
[nodeValue] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
[nodeType] => 1
[parentNode] => (object value omitted)
[parentElement] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => (object value omitted)
[nextSibling] =>
[attributes] => (object value omitted)
[isConnected] => 1
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
)
)
- Output for 8.1.22 - 8.1.28, 8.2.9 - 8.2.18
- object(DOMNodeList)#11 (1) {
["length"]=>
int(8)
}
Array
(
[0] => DOMElement Object
(
[schemaTypeInfo] =>
[tagName] => table
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] =>
[nextElementSibling] => (object value omitted)
[nodeName] => table
[nodeValue] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] => (object value omitted)
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
)
[1] => DOMElement Object
(
[schemaTypeInfo] =>
[tagName] => table
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] => (object value omitted)
[nextElementSibling] =>
[nodeName] => table
[nodeValue] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => (object value omitted)
[nextSibling] =>
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
)
)
- Output for 8.1.0 - 8.1.21, 8.2.0 - 8.2.8
- object(DOMNodeList)#11 (1) {
["length"]=>
int(8)
}
Array
(
[0] => DOMElement Object
(
[schemaTypeInfo] =>
[tagName] => table
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] =>
[nextElementSibling] => (object value omitted)
[nodeName] => table
[nodeValue] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] => (object value omitted)
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
)
[1] => DOMElement Object
(
[schemaTypeInfo] =>
[tagName] => table
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] => (object value omitted)
[nextElementSibling] =>
[nodeName] => table
[nodeValue] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => (object value omitted)
[nextSibling] =>
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
)
)
- Output for 8.0.30
- object(DOMNodeList)#11 (1) {
["length"]=>
int(8)
}
Array
(
[0] => DOMElement Object
(
[tagName] => table
[schemaTypeInfo] =>
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] =>
[nextElementSibling] => (object value omitted)
[nodeName] => table
[nodeValue] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] => (object value omitted)
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
)
[1] => DOMElement Object
(
[tagName] => table
[schemaTypeInfo] =>
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] => (object value omitted)
[nextElementSibling] =>
[nodeName] => table
[nodeValue] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => (object value omitted)
[nextSibling] =>
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] =>
Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
)
)
- Output for 8.0.0 - 8.0.29
- object(DOMNodeList)#11 (1) {
["length"]=>
int(8)
}
Array
(
[0] => DOMElement Object
(
[tagName] => table
[schemaTypeInfo] =>
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] =>
[nextElementSibling] => (object value omitted)
[nodeName] => table
[nodeValue] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] => (object value omitted)
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
)
[1] => DOMElement Object
(
[tagName] => table
[schemaTypeInfo] =>
[firstElementChild] => (object value omitted)
[lastElementChild] => (object value omitted)
[childElementCount] => 1
[previousElementSibling] => (object value omitted)
[nextElementSibling] =>
[nodeName] => table
[nodeValue] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => (object value omitted)
[nextSibling] =>
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
)
)
- Output for 7.0.20, 7.1.5 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
- object(DOMNodeList)#11 (1) {
["length"]=>
int(8)
}
Array
(
[0] => DOMElement Object
(
[tagName] => table
[schemaTypeInfo] =>
[nodeName] => table
[nodeValue] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] => (object value omitted)
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
)
[1] => DOMElement Object
(
[tagName] => table
[schemaTypeInfo] =>
[nodeName] => table
[nodeValue] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => (object value omitted)
[nextSibling] =>
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
)
)
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.6, 7.1.0
- object(DOMNodeList)#11 (1) {
["length"]=>
int(8)
}
Array
(
[0] => DOMElement Object
(
[tagName] => table
[schemaTypeInfo] =>
[nodeName] => table
[nodeValue] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] =>
[nextSibling] => (object value omitted)
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13115 - 2010
)
[1] => DOMElement Object
(
[tagName] => table
[schemaTypeInfo] =>
[nodeName] => table
[nodeValue] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
[nodeType] => 1
[parentNode] => (object value omitted)
[childNodes] => (object value omitted)
[firstChild] => (object value omitted)
[lastChild] => (object value omitted)
[previousSibling] => (object value omitted)
[attributes] => (object value omitted)
[ownerDocument] => (object value omitted)
[namespaceURI] =>
[prefix] =>
[localName] => table
[baseURI] =>
[textContent] => Juzgado PolicÃa Local
Rol Causa
2 JPL PROVIDENCIA
018092 - 2010
OVALLE JPL
13116 - 2011
)
)
preferences:
194.71 ms | 410 KiB | 213 Q