Hi all,
The following code works fine to convert mysql to xml but one of my databases contains html tags e.g. I get an error when trying to put a </p> tag in the xml. My code is:
<?
header("Content-type: text/xml");
$db_name = "Dynamic"; //This is your database Name
$link = mysql_connect("localhost", "root", "") or die("Could not connect to server!");
//This is your table name. This is a one table config to do more table you will need to rework the code.
$table_name = 'Dynamic';
$select_db = mysql_select_db($db_name, $link); // mysql_select_db -- Select a MySQL database
$query = "SELECT * FROM " . $table_name;
$result = mysql_query($query, $link) or die("Could not complete database query");
$fcount = mysql_num_fields($result);
print "<result>";
while($row = mysql_fetch_array( $result ) ){
print "<row>";
for($i=0; $i< $fcount; $i++){
$tag = mysql_field_name( $result, $i );
print "<$tag>". $row[$i]. "</$tag>";
}
print "</row>";
}
?>
Is there a way of either ignoring the html tags or parsing them to be accepted ?
Thanks in advance 🙂