Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have this code:

$rss = '<?xml version="1.0" encoding="ISO-8859-1" ?>';
		$rss .= '<rss version="2.0">';
		$rss .= '<channel>';
		$rss .= '<title>Lavasoft</title>';
		$rss .= '<link>/blog</link>';
		$rss .= '<description>Malware Encyclopedia</description>';
		
		$result = mysql_query('SELECT title, teaser, timestamp FROM blog', $db);
		while($row = mysql_fetch_array($result)) {
			$rss .= '<item>';
			$rss .= '<title>'.$row['title'].'</title>';
			$rss .= '<link>'.'/blog/'.$row['title'].'</link>';
			$rss .= '<description>'.$row['teaser'].'</description>';
			$rss .= '<pubDate>'.$row['timestamp'].'</pubDate>';
			$rss .= '</item>';
		}
		
		$rss .= '</channel>';
		$rss .= '</rss>';


How to auto write to xml when there's new update?
Posted

1 solution

Of course, it's never good to create XML in such an ad-hoc way you demonstrated. There are plenty of civilized alternatives. Please see:
http://www.w3schools.com/php/php_xml_simplexml.asp[^],
http://www.w3schools.com/php/php_xml_dom.asp[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900