Here I will show you how to generate XMl file dynamicaly suing PHP.
<?php
ob_start();
session_start();
include("autoload.php");
$db = new MySql();
$db->connect();
$rf=new User();
$f=$rf->getproperty();
$myFile = "/var/www/xmlold/Homein.xml";
$fp = fopen($myFile, 'w') or die("can't open file");
//$fp=fopen("/var/www/xmlold/Homein.txt",'w');
fwrite($fp,"<?xml version='1.0' ?>\n");
fwrite($fp,"<properties>\n");
for($i=0;$i<count($f);$i++){
fwrite($fp,"<property>\n");
fwrite($fp,"<title>".$f[$i]['property_header']."</title>\n");
fwrite($fp,"<reference_code>".$f[$i]['reference']."</reference_code>\n");
fwrite($fp,"<listing_section>".$f[$i]['method']."</listing_section>\n");
fwrite($fp,"<property_type>".$f[$i]['type_name']."</property_type>\n");
fwrite($fp,"<street>".$f[$i]['emirates'],$f[$i]['location'],$f[$i]['project_name']."</street>\n");
fwrite($fp,"<price>".$f[$i]['price']."</price>\n");
fwrite($fp,"<bedrooms>".$f[$i]['no_bedrooms']."</bedrooms>\n");
fwrite($fp,"<description>".$f[$i]['description']."</description>\n");
fwrite($fp,"</property>\n");
}
fwrite($fp,"</properties>\n");
fclose($fp);
?>
<?php
ob_start();
session_start();
include("autoload.php");
$db = new MySql();
$db->connect();
$rf=new User();
$f=$rf->getproperty();
$myFile = "/var/www/xmlold/Homein.xml";
$fp = fopen($myFile, 'w') or die("can't open file");
//$fp=fopen("/var/www/xmlold/Homein.txt",'w');
fwrite($fp,"<?xml version='1.0' ?>\n");
fwrite($fp,"<properties>\n");
for($i=0;$i<count($f);$i++){
fwrite($fp,"<property>\n");
fwrite($fp,"<title>".$f[$i]['property_header']."</title>\n");
fwrite($fp,"<reference_code>".$f[$i]['reference']."</reference_code>\n");
fwrite($fp,"<listing_section>".$f[$i]['method']."</listing_section>\n");
fwrite($fp,"<property_type>".$f[$i]['type_name']."</property_type>\n");
fwrite($fp,"<street>".$f[$i]['emirates'],$f[$i]['location'],$f[$i]['project_name']."</street>\n");
fwrite($fp,"<price>".$f[$i]['price']."</price>\n");
fwrite($fp,"<bedrooms>".$f[$i]['no_bedrooms']."</bedrooms>\n");
fwrite($fp,"<description>".$f[$i]['description']."</description>\n");
fwrite($fp,"</property>\n");
}
fwrite($fp,"</properties>\n");
fclose($fp);
?>
wow!! Thanks litto... :)
ReplyDelete