Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Emerson Placido

Xml e PHP

Recommended Posts

TENHO ESTE CODIGO DE XML, MAS ELE NÃO MOSTRA O ERRO.

 

 

<?php
$arquivo = 'http://hosting.gmodules.com/ig/gadgets/file/100025145397458874742/climatempo_weather_gadget.xml';

function LeXML( $arquivo, $num_noticias, $thistag, $tag_deep, $noticia_ini, $codificacao )
{
	 if( !( $abrearquivo = fopen( $arquivo, 'r' ) ) )
	 {
		 die( "<strong>Falha ao carregar dados.</strong>" );
	 }
	
	 while (!feof($abrearquivo)) {
		 $xml = $xml . fgets($abrearquivo);
	 }
	
	 $parser = xml_parser_create();
	 xml_parse_into_struct($parser, $xml, $dados, $index);
	 xml_parser_free($parser);
	
	 $count = 0;
	 for( $i = 0; $i < sizeof( $dados ); $i++ )
	 {
		 if( $dados[ $i ][ "tag" ] == "LINK" && $dados[ $i ][ "level" ] == $tag_deep )
		 {
			 if( $count < $num_noticias + $noticia_ini )
			 {
				 if( $count >= $noticia_ini )
				 {
					 $link[$count] = '<a href="' . $dados[ $i ]["value"] . '" TARGET="_blank">';
				 }
				 $count++;
			 }
		 }
	 }
	
	 $count = 0;
	 for( $i = 0; $i < sizeof( $dados ); $i++ )
	 {
		 if( $dados[ $i ][ "tag" ] == $thistag && $dados[ $i ][ "level" ] == $tag_deep )
		 {
			 if( $count < $num_noticias + $noticia_ini )
			 {
				 if( $count >= $noticia_ini )
				 {
					 if( $codificacao == "UTF-8" )
					 {
						 echo addslashes($link[$count]) . addslashes(utf8_decode($dados[ $i ]["value"])) . "'</a>";
					 }
					 else if( $codificacao == "ISO-8859-1" )
					 {
						 echo addslashes($link[$count]) . addslashes($dados[ $i ]["value"]) . "'</a>";
					 }
				 }
				 $count++;
			 }
		 }
	 }
}
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

A reportagem de erros está habilitada no servidor que você está usando para desenvolver ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.