You are here: Re: problem to open a distant XML file in PHP « PHP Programming Language « IT news, forums, messages
Re: problem to open a distant XML file in PHP

Posted by sumguyovrthar on 02/15/07 02:28

On Feb 13, 11:35 am, Claire DURAND <claidur...@NOSPAMyahoo.fr> wrote:
> Hi,
>
> I try to open a distant (not local) XML file in PHP to read an RSS feed.
>
> I can open an HTML page and read it with the file() function.
>
> But as soon as I try with a RSS feed instead of HTML and I try to read
> or open with file() or fopen(), it doesn't work, I have the following
> errors :
>
> Warning: fopen() [function.fopen]: php_hostconnect: connect failed in
> D:\test.php on line 10
>
> Warning: fopen(http://www.clubic.com/xml/news.xml) [function.fopen]:
> failed to create stream: Bad file descriptor in D:\test.php on line 10
>
> In my phpinfo, the parameters are like this :
> PHP Version 4.3.1
> Registered PHP Streams php, http, ftp, compress.zlib
> allow_url_fopen On On
> XML Support active
> XML Namespace Support active
> EXPAT Version 1.95.2
>
> My source file is :
> <?php
> $fichier_xml = "http://www.clubic.com/xml/news.xml";
> $file = fopen($fichier_xml,"r");
> ?>
>
> Could someone help me ?
>
> Thanks.
>
> (Sorry for my "frenchynglish")

You can't use fopen() on remote files. Try this instead:
$file = implode( '', file( $$fichier_xml ) );

That will put the entire rss feed into the $file variable for you to
parse or whatever

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация