Hello all... I've something of a problem. For the life of me, I've been horribly unable to parse a twitter feed into something *writable to a text file.* There is tons of code out there to fetch the feed, replace the funky symbols etc etc, but I cannot figure out how to turn the screen display into a writable-to-text using fwrite() array or whatever. Essentially, I can't figure out how to turn: <a href="http://twitter.com/">web</a> sicsemperhomo (Theodore) http://twitter.com/sicsemperhomo tag:search.twitter.com,2005:1221756053 2009-02-18T04:50:07Z He had it coming. 2009-02-18T04:50:07Z <a href="http://twitter.com/">web</a> sicsemperhomo (Theodore) http://twitter.com/sicsemperhomo tag:search.twitter.com,2005:1221753403 2009-02-18T04:49:03Z <a href="http://twitter.com/emilyc808">@emilyc808</a> So, dah-ling, I hear that you didn't recognize me in my picture behind a glass door with a flash obscuring my face. 2009-02-18T04:49:03Z <a href="http://twitter.com/">web</a> sicsemperhomo (Theodore) http://twitter.com/sicsemperhomo tag:search.twitter.com,2005:1214279357 2009-02-16T04:16:54Z I wonder why _Brothers & Sisters_ starting using the _Angels in America_ oboe motif. ......... etc etc Code (markup): INTO # He had it coming. # @emilyc808 So, dah-ling, I hear that you didn't recognize me in my picture behind a glass door with a flash obscuring my face. # I wonder why _Brothers & Sisters_ starting using the _Angels in America_ oboe motif. # I wish I could find someone who knows twitter api to help me out with a project... any takers? # Blue sunlight is the product of IKEA curtains and mimosas. Woof. And write it to a text file. Thanks so much. It's driving me absolutely crazy. Here's the code I'm working with, and it's writing the WHOLE xml garbage into the file: <?php // Define username and how much to pull; cleanup output with li $username = "sicsemperhomo"; $limit = "15"; $prefix = "<ul>"; $suffix = "</ul>"; $pretweet = "<li>"; $posttweet = "</li>"; $feed = "http://search.twitter.com/search.atom?q=from:" . $username . " . $limit . "; function parse_feed($feed, $prefix, $pretweet, $posttweet, $suffix) { //Beautify. $feed = str_replace("<", "<", $feed); $feed = str_replace(">", ">", $feed); $feed = str_replace("&", "&", $feed); $feed = str_replace(""", "\"", $feed); //Create a clean version of the code in html and overwrite the $feed string telling it to use cont... as the dynamite. $clean = explode("<content type=\"html\">", $feed); //Establish the number of times the php should loop by counting the number of clean lines minus 1. $amount = count($clean) - 1; echo $prefix; //Looptastic magic for ($i = 1; $i <= $amount; $i++) { $cleaner = explode("</content>", $clean[$i]); echo $pretweet; echo $cleaner[0]; echo $posttweet; } echo $suffix; } $twitterFeed = file_get_contents($feed); echo $twitterFeed; parse_feed($twitterFeed, $prefix, $pretweet, $posttweet, $suffix); $codex = "RecentTwitters.txt"; $codexhandle = fopen($codex, 'a') or die("Cannot perform up to standard. I need the attention of a webcoder."); fwrite($codexhandle, $twitterFeed); fclose($codexhandle); echo "<br /> <br />D.V. 'Tis done."; ?> Code (markup): Danke.
load the file into a simplexml object: http://www.php.net/manual/en/function.simplexml-load-file.php Then loop through the contents - see the example by "aero" to loop through recursively and change the "print" line to do what you need ... : http://www.php.net/manual/en/function.simplexml-element-children.php