I am currently trying to implement XML Parsing on a site using the XML News Feed of another site. The site puts two versions of the news in its file though:
- <item> <title>Tsunami 2265 Date, Demo</title> <link>http://www.shacknews.com/onearticle.x/20959</link> </item> - <ITEM> <SUBJECT>Tsunami 2265 Date, Demo</SUBJECT> <URL>http://www.shacknews.com/onearticle.x/20959</URL> <CATEGORY>General</CATEGORY> </ITEM> I have a script that is meant to parse the file which is downloaded to a local file hourly. The trouble is that the script tries parsing both lots and I only wish it to parse the top half and to stop when it reaches the entries using <SUBJECT> tags. Does anyone have a solution for this? The script below is what I use to echo the news onto my site. The script attached is the script that is meant to parse the xml document. <? include( "includes/xmlfeed.php" ); $rdffile = "shacknews.xml"; $remote = "http://www.shacknews.com/shackfeed.xml"; $refreshtime = time() - 3600; ?> <? if ((filemtime($rdffile) < $refreshtime) || (filesize($rdffile) == 0)) { $RDF = fopen( $rdffile, "w" ) or die( "Cannot open $rdffile" ); $FILE = fopen( $remote, "r" ) or die( "Cannot open $remote" ); while (!feof( $FILE )) { fwrite( $RDF, fgets( $FILE, 1024 )); } fclose( $RDF ); fclose( $FILE ); } parseRDF( $rdffile ); ?> ----- Andrew.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php