Click to See Complete Forum and Search --> : Need help with PHP and XML to TXT


Trajecto
01-16-2006, 09:54 PM
I need to write a PHP script that when run reads in an XML RSS feed like this: http://www.usatoday.com/repurposing/OffbeatRss.xml and writes out just the text to a simple text file.

I'm pretty green at PHP, any tips on how to start or snippets would be greatly appreciated!

ShrineDesigns
01-16-2006, 10:03 PM
your example uses xml and xsl

Trajecto
01-16-2006, 10:34 PM
How about something like this:

http://my.abcnews.go.com/rsspublic/world_rss20.xml

I need to read everything in as a string and parse out everything between the "< >" then write out a text file.

Huevoos
01-16-2006, 10:58 PM
I don't quite understand what you want, but look at this link, if this is what you'r looking for I can post the messy source code

http://www.esbasura.com/rss.php?rss=abcnews

(there is a little prob with the links with <!CDATA but is easy to get through)

Trajecto
01-16-2006, 11:07 PM
It would just be a dump of the contents as a text file. So it wouldn't even be an HTML page, just a "news.txt" file.

Huevoos
01-16-2006, 11:13 PM
something like
http://www.esbasura.com/escroto.txt ???

Huevoos
01-16-2006, 11:27 PM
well the code for that is

$ch = curl_init("http://my.abcnews.go.com/rsspublic/world_rss20.xml");
$fp = fopen("escroto.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);


assuming you have the curl library

Trajecto
01-17-2006, 05:19 AM
That looks like what I want! I need to remove the "< >" brackets and everything between them though.

Is this where you get curl at?: http://curl.haxx.se/

Markbad311
01-17-2006, 07:51 AM
can someone define the Curl Library I am a newbie and trying tio pick up on anything my book hasn't taught me.

Huevoos
01-17-2006, 11:46 AM
Yep that's where you get the curl library
I don't know if strip_tags() will work with xml Why don't you give it a try.

Markbad: http://php.net/curl