# XML output via PHP

**URL:** <https://forum.kirupa.com/t/xml-output-via-php/124455>\
**Category:** Uncategorized\
**Created:** [October 3, 2004, 11:57pm UTC](https://forum.kirupa.com/t/xml-output-via-php/124455 "2004-10-03T23:57:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lbeetles](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@lbeetles](https://forum.kirupa.com/u/lbeetles)\
**Post date:** [October 3, 2004, 11:57pm UTC](https://forum.kirupa.com/t/xml-output-via-php/124455/1 "2004-10-03T23:57:53Z")

</div>

I hope someone can help me out, with this.

I am getting data from a MySql database via php and outputting it into xml.

Here is my code:

```php
<? 
 
include("connect.php");
 
header("Content-type: text/xml"); 
 
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); 
mysql_select_db($database, $linkID) or die("Could not find database."); 
 
$query = "SELECT head_entry, text_entry, DATE_FORMAT(add_date, '%d %b %Y, %H:%i') as vtime FROM newsbox WHERE active = 'y' ORDER BY add_date DESC"; 
$result = mysql_query($query, $linkID) or die("Data not found."); 
 
$xml_output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
"; 
$xml_output .= "<menu>
"; 
 
for ($x = 0; $x < mysql_num_rows($result) ; $x++){ 
$row = mysql_fetch_assoc($result); 
 
$xml_output .= "	<item head =\"" . "&lt;b&gt;" . $row['head_entry'] . "&lt;/b&gt;" . "\" entry =\"" . $row['text_entry'] . "\" date =\"" . $row['vtime'] . "\" >
"; 
 
$xml_output .= "	</item>
"; 
} 
 
$xml_output .= "</menu>"; 
 
print $xml_output; 
 
?>

```

My problem is that i need to have links, bold and italic in there. How would i get php to detect \<b\>\</b\>, \<i\>\</i\>, \<a href=\>\</a\> and change it so xml can understand it and output the result correctly.

Would i have to use CDATA and if so, how???

Cheers

Lee
