MySQL to XML file

ENOS

New Member
I am trying to get MySQL database into an xml file; here is my code:\[code\] <?php header("Content-type: text/xml"); include 'dbc.php'; $query = "SELECT * FROM airports"; $result = mysql_query($query, $link) or die('Error querying database.'); $xml = new SimpleXMLElement('<xml/>'); while($row = mysql_fetch_assoc($result)) { $draw = $xml->addChild('draw'); $draw->addChild('title',$row['ident']); $draw->addChild('url',$row['name']); } mysql_close($link); $fp = fopen("xml/links2.xml","wb"); fwrite($fp,$xml->asXML()); fclose($fp);\[/code\]Here is the error Im getting:\[code\] XML Parsing Error: junk after document element Location: http://www.fpmnky.com/sql2xml2.php Line Number 2, Column 1:<b>Warning</b>: SimpleXMLElement::addChild() [<a href='http://stackoverflow.com/questions/13785172/simplexmlelement.addchild'>simplexmlelement.addchild</a>]: unterminated entity reference Women's Health Centre) Helip in <b>/home/wwwfligh/public_html/sql2xml2.php</b> on line <b>16</b><br /> ^\[/code\]What am I doing wrong???
 
Back
Top