ARTIS Posted September 15, 2009 Share Posted September 15, 2009 Hi, I am not a php programmer and need some help getting an xml feed property written to the web browser. The data is being retrieved from a mysql database. See my feed at: http://www.visualshows.com/test.php When I view the source behind the page, the XML Tags are there. What I don't understand is why the tags are not seen in the browser window as they are on this site: http://www.blueonerealty.com/rss_feed/xml_homes/trulia.php Can someone please give me some guidance? My coded is below Thanks! Graham <?php [Database stuff here] mysql_connect($sql_host,$sql_user,$sql_pass); mysql_select_db($sql_db); $result = mysql_query('SELECT * from SyndicationExport'); $doc = new DomDocument('1.0','UTF-8'); $root = $doc->createElement('SyndicationExport'); $root = $doc->appendChild($root); while($row = mysql_fetch_assoc($result)) { // add node for each record $listing= $doc->createElement('listing'); $listing = $root->appendChild($listing); foreach($row as $fieldname => $fieldvalue) { $child = $doc->createElement($fieldname); $child = $listing->appendChild($child); //add data to the new element $value = $doc->createTextNode($fieldvalue); $value = $child->appendChild($value); } } echo $doc->saveXML(); ?> Link to comment https://forums.phpfreaks.com/topic/174277-creating-xml-feed-to-browser/ Share on other sites More sharing options...
RussellReal Posted September 15, 2009 Share Posted September 15, 2009 header('content-type: text/xml'); Link to comment https://forums.phpfreaks.com/topic/174277-creating-xml-feed-to-browser/#findComment-918732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.