Jump to content

Creating XML Feed to Browser


ARTIS

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.