Jump to content
Fórum Script Brasil
  • 0

Ler XML e imprimir array PHP


DiegoM

Question

eai galera, to usando esse código para ler um arquivo em XML e imprimir via php na tela.

<table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                      <?php $xml = simplexml_load_file("http://www3.uol.com.br/parceiros/noticias/clic-doutor.xml");
                    $z = 0;
                    foreach($xml->item as $item)
                    {
                        if ($z == 5) { break;}
                        ?>
                        <td valign="top" align="center" width="19%"><a href="<?php echo urldecode($item->url); ?>"><?php echo $item->title; ?></a></</td>
                        <td valign="top" align="center" class="sep-news">&bull;</td>
                        <?php
                    $z++;}
                    ?> 
                  </tr>
                </table>
No chrome e no IE está funcionando normalmente, mas no Firefox ele está gerando o link asssim
http://localhost/meusite/%0A%09%09%09http://noticias.uol.com.br/ultnot/cienciaesaude/ultimas-noticias/efe/2011/09/28/comecam-pesquisas-em-antimateria-que-podem-desvendar-origem-do-universo.jhtm%0A%09%09

alguém tem idéia o que pode ser?

fico no aguardo e obrigado.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Diego,

fiz um teste aqui e funcionou no FF,IE,Chome

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html lang="pt-br">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    </head>
    <body><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                      <?php $xml = simplexml_load_file("http://www3.uol.com.br/parceiros/noticias/clic-doutor.xml");
                    $z = 0;
                    foreach($xml->item as $item)
                    {
                        if ($z == 5) { break;}
                        ?>
                        <td valign="top" align="center" width="19%"><a href="<?php echo urldecode($item->url); ?>"><?php echo $item->title; ?></a></</td>
                        <td valign="top" align="center" class="sep-news">&bull;</td>
                        <?php
                    $z++;}
                    ?>
                  </tr>
                </table>
</body>
</html>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...