Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa noite, pessoal! Estou tentando encontrar a melhor solução para organizar os dados que estou obtendo através de um XML. A estrutura do XML está vindo de uma tabela dessa forma: /applications/core/interface/imageproxy/imageproxy.php?img=http://i.imgur.com/xYp201F.png?1&key=9c476bbd04beac1ee80dba87de3cfdf71e4786602d547345abf4ace751f1a20d" alt="xYp201F.png?1" /> Estou utilizando o Yahoo! YQL e ele me retorna o seguinte XML com o código abaixo:
$table = getYqlResult(" select * from html where url = '$url' and xpath='//tr' ", 'xml'). function getYqlResult($query){ $yql_base_url = "http://query.yahooapis.com/v1/public/yql". $yql_query_url = $yql_base_url. "?q=". urlencode($query). return simplexml_load_file($yql_query_url). } foreach ($table->results->tr as $node) { echo '<pre>'. echo($node->td[0]->p). echo($node->td[1]->p). echo '</pre>'. } <?xml version="1.0" encoding="UTF-8"?><query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="20" yahoo:created="2013-12-01T21:22:57Z" yahoo:lang="en-US"> <results> <tr class="dr-table-subheader rich-table-subheader Grid-Titulo"> <th class="dr-table-subheadercell rich-table-subheadercell Grid-Titulo" id="j_id_jsp_52511974_1:tbGridIda:j_id_jsp_52511974_7header" scope="col"> <div id="j_id_jsp_52511974_1:tbGridIda:j_id_jsp_52511974_7header:sortDiv"> <p>Sequência</p> </div> </th> <th class="dr-table-subheadercell rich-table-subheadercell Grid-Titulo" id="j_id_jsp_52511974_1:tbGridIda:j_id_jsp_52511974_10header" scope="col"> <div id="j_id_jsp_52511974_1:tbGridIda:j_id_jsp_52511974_10header:sortDiv"> <p>Via</p> </div> </th> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:0:j_id_jsp_52511974_7"> <p>001</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:0:j_id_jsp_52511974_10"> <p>TERMINAL CONJ. GRACILIANO RAMOS</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:1:j_id_jsp_52511974_7"> <p>002</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:1:j_id_jsp_52511974_10"> <p>AV. EMP. NELSON OLIVEIRA MENEZES</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:2:j_id_jsp_52511974_7"> <p>003</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:2:j_id_jsp_52511974_10"> <p>AV. DA PAZ</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:3:j_id_jsp_52511974_7"> <p>004</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:3:j_id_jsp_52511974_10"> <p>ITINERARIO VOLTA - B. GONZAGA</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:4:j_id_jsp_52511974_7"> <p>005</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:4:j_id_jsp_52511974_10"> <p>AV. TANCREDO NEVES</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:5:j_id_jsp_52511974_7"> <p>006</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:5:j_id_jsp_52511974_10"> <p>RUA SAO PEDRO</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:6:j_id_jsp_52511974_7"> <p>007</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:6:j_id_jsp_52511974_10"> <p>RUA GABINO BEZOURO</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:7:j_id_jsp_52511974_7"> <p>008</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridIda:7:j_id_jsp_52511974_10"> <p>RUA FLORENCIO DE ABREU</p> </td> </tr> <tr class="dr-table-subheader rich-table-subheader Grid-Titulo"> <th class="dr-table-subheadercell rich-table-subheadercell Grid-Titulo" id="j_id_jsp_52511974_1:tbGridVolta:j_id_jsp_52511974_16header" scope="col"> <div id="j_id_jsp_52511974_1:tbGridVolta:j_id_jsp_52511974_16header:sortDiv"> <p>Sequência</p> </div> </th> <th class="dr-table-subheadercell rich-table-subheadercell Grid-Titulo" id="j_id_jsp_52511974_1:tbGridVolta:j_id_jsp_52511974_19header" scope="col"> <div id="j_id_jsp_52511974_1:tbGridVolta:j_id_jsp_52511974_19header:sortDiv"> <p>Via</p> </div> </th> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:0:j_id_jsp_52511974_16"> <p>001</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:0:j_id_jsp_52511974_19"> <p>RUA FLORENCIO DE ABREU</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:1:j_id_jsp_52511974_16"> <p>002</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:1:j_id_jsp_52511974_19"> <p>RUA 01 - VILLAGE I</p> </td> </tr><tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:2:j_id_jsp_52511974_16"> <p>003</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:2:j_id_jsp_52511974_19"> <p>RUA SAO PEDRO</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:3:j_id_jsp_52511974_16"> <p>004</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:3:j_id_jsp_52511974_19"> <p>AV. TANCREDO NEVES</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:4:j_id_jsp_52511974_16"> <p>005</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:4:j_id_jsp_52511974_19"> <p>RUA BENEDITO CALACA LOUREIRO</p> </td> </tr><tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:5:j_id_jsp_52511974_16"> <p>006</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:5:j_id_jsp_52511974_19"> <p>RUA PERIMETRAL 03</p> </td> </tr><tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:6:j_id_jsp_52511974_16"> <p>007</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:6:j_id_jsp_52511974_19"> <p>RUA JOSE MAILTON DOS SANTOS</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:7:j_id_jsp_52511974_16"> <p>008</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:7:j_id_jsp_52511974_19"> <p>RUA 01</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:8:j_id_jsp_52511974_16"> <p>009</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:8:j_id_jsp_52511974_19"> <p>TERMINAL CONJ. GRACILIANO RAMOS</p> </td> </tr> <tr class="dr-table-firstrow rich-table-firstrow"> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:9:j_id_jsp_52511974_16"> <p>010</p> </td> <td class="dr-table-cell rich-table-cell Grid-Registro" id="j_id_jsp_52511974_1:tbGridVolta:9:j_id_jsp_52511974_19"> <p>AV. EMP. NELSON OLIVEIRA MENEZES</p> </td> </tr> </results></query><!-- total: 1275 --><!-- engine1.yql.bf1.yahoo.com --> Qual a melhor forma para que eu organize os dados e obtenha os valores que estão dentro do atributo <p>? Pois terei de organizar esses dados e inseri-los num banco de dados. Alguma alternativa a solução?Obrigado pela resposta, DilsonMarcos. Infelizmente não é o suficiente para sanar o problema.
Veja que estou tentando obter todos os valores dentro da tag <p>, utilizando o código abaixo para exibi-los e gostaria de uma maneira alternativa pois
foreach ($table->results->tr as $node) {
echo '<pre>';
echo($node->td[0]->p);
echo($node->td[1]->p);
echo '</pre>';
}
Veja que estou dando echo em dois $node, pois se eu der somente um, só é exibido a primeira tag <p> que seria a "sequência".Dando um print_r na variável $table, obtenho o seguinte:
SimpleXMLElement Object
(
[results] => SimpleXMLElement Object
(
[tr] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-subheader rich-table-subheader Grid-Titulo
)
[th] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-subheadercell rich-table-subheadercell Grid-Titulo
[id] => j_id_jsp_52511974_1:tbGridIda:j_id_jsp_52511974_7header
[scope] => col
)
[div] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => j_id_jsp_52511974_1:tbGridIda:j_id_jsp_52511974_7header:sortDiv
)
[p] => Sequência
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-subheadercell rich-table-subheadercell Grid-Titulo
[id] => j_id_jsp_52511974_1:tbGridIda:j_id_jsp_52511974_10header
[scope] => col
)
[div] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => j_id_jsp_52511974_1:tbGridIda:j_id_jsp_52511974_10header:sortDiv
)
[p] => Via
)
)
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:0:j_id_jsp_52511974_7
)
[p] => 001
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:0:j_id_jsp_52511974_10
)
[p] => TERMINAL CONJ. GRACILIANO RAMOS
)
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:1:j_id_jsp_52511974_7
)
[p] => 002
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:1:j_id_jsp_52511974_10
)
[p] => AV. EMP. NELSON OLIVEIRA MENEZES
)
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:2:j_id_jsp_52511974_7
)
[p] => 003
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:2:j_id_jsp_52511974_10
)
[p] => AV. DA PAZ
)
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:3:j_id_jsp_52511974_7
)
[p] => 004
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:3:j_id_jsp_52511974_10
)
[p] => ITINERARIO VOLTA - B. GONZAGA
)
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:4:j_id_jsp_52511974_7
)
[p] => 005
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:4:j_id_jsp_52511974_10
)
[p] => AV. TANCREDO NEVES
)
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:5:j_id_jsp_52511974_7
)
[p] => 006
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:5:j_id_jsp_52511974_10
)
[p] => RUA SAO PEDRO
)
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:6:j_id_jsp_52511974_7
)
[p] => 007
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:6:j_id_jsp_52511974_10
)
[p] => RUA GABINO BEZOURO
)
)
)
[8] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:7:j_id_jsp_52511974_7
)
[p] => 008
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridIda:7:j_id_jsp_52511974_10
)
[p] => RUA FLORENCIO DE ABREU
)
)
)
[9] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-subheader rich-table-subheader Grid-Titulo
)
[th] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-subheadercell rich-table-subheadercell Grid-Titulo
[id] => j_id_jsp_52511974_1:tbGridVolta:j_id_jsp_52511974_16header
[scope] => col
)
[div] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => j_id_jsp_52511974_1:tbGridVolta:j_id_jsp_52511974_16header:sortDiv
)
[p] => Sequência
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-subheadercell rich-table-subheadercell Grid-Titulo
[id] => j_id_jsp_52511974_1:tbGridVolta:j_id_jsp_52511974_19header
[scope] => col
)
[div] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => j_id_jsp_52511974_1:tbGridVolta:j_id_jsp_52511974_19header:sortDiv
)
[p] => Via
)
)
)
)
[10] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:0:j_id_jsp_52511974_16
)
[p] => 001
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:0:j_id_jsp_52511974_19
)
[p] => RUA FLORENCIO DE ABREU
)
)
)
[11] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:1:j_id_jsp_52511974_16
)
[p] => 002
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:1:j_id_jsp_52511974_19
)
[p] => RUA 01 - VILLAGE I
)
)
)
[12] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:2:j_id_jsp_52511974_16
)
[p] => 003
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:2:j_id_jsp_52511974_19
)
[p] => RUA SAO PEDRO
)
)
)
[13] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:3:j_id_jsp_52511974_16
)
[p] => 004
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:3:j_id_jsp_52511974_19
)
[p] => AV. TANCREDO NEVES
)
)
)
[14] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:4:j_id_jsp_52511974_16
)
[p] => 005
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:4:j_id_jsp_52511974_19
)
[p] => RUA BENEDITO CALACA LOUREIRO
)
)
)
[15] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:5:j_id_jsp_52511974_16
)
[p] => 006
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:5:j_id_jsp_52511974_19
)
[p] => RUA PERIMETRAL 03
)
)
)
[16] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:6:j_id_jsp_52511974_16
)
[p] => 007
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:6:j_id_jsp_52511974_19
)
[p] => RUA JOSE MAILTON DOS SANTOS
)
)
)
[17] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:7:j_id_jsp_52511974_16
)
[p] => 008
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:7:j_id_jsp_52511974_19
)
[p] => RUA 01
)
)
)
[18] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:8:j_id_jsp_52511974_16
)
[p] => 009
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:8:j_id_jsp_52511974_19
)
[p] => TERMINAL CONJ. GRACILIANO RAMOS
)
)
)
[19] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-firstrow rich-table-firstrow
)
[td] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:9:j_id_jsp_52511974_16
)
[p] => 010
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[class] => dr-table-cell rich-table-cell Grid-Registro
[id] => j_id_jsp_52511974_1:tbGridVolta:9:j_id_jsp_52511974_19
)
[p] => AV. EMP. NELSON OLIVEIRA MENEZES
)
)
)
)
)
)Bem, consegui resolver da seguinte forma e utilizando xpath:
$node = $table->xpath('//results/tr/td/p');
$i = 0;
$j = 1;
echo("<table border='1'>");
foreach($node as $item)
{
if ($i % 2 == 0)
{
echo "<tr>";
echo "<td>";
echo $item;
echo "</td>";
}
if ($j % 2 == 0)
{
echo "<td>";
echo $item;
echo "</td>";
echo "</tr>";
}
$i++;
$j++;
}
echo("</table>");
Se for para ler e inserir em um banco:
http://forum.imasters.com.br/topic/512628-ajuda-j-to-3-dia-nisso-nisso-s-vocs-mesmo-para-me-ajudar/