I fetched some records from a table named a2h_member in php. i want to convert it into XML format. How can i do this?. Give me some suggestions or code. Please Help me
A:
longneck
2009-09-16 14:23:27
that was so RTFM ....
RageZ
2009-09-16 14:24:34
I know how to search in google
Rajasekar
2009-09-16 14:24:57
+2
A:
the simplier the best
$xml = '<?xml version="1.0" encoding="UTF-8" ?><result>';
foreach($result as $row){
xml .= '<row>';
foreach($row as $key=>$value){
$xml .= "<{$key}><![CDATA[{$value}]]></{$key}>";
}
$xml .= '</row>'
}
$xml .= '</result>';
RageZ
2009-09-16 14:24:04
I'd recommend against using magic quotes here. Magic quotes are discouraged and soon to be deprecated. Just do the explicit string concatenation.
Jonathan Fingland
2009-09-16 14:34:00
@Jonathan Fingland: This code doesn't use magic quotes, it uses variable expansion, which I don't expect ever to be deprecated. Variable expansion in double-quoted strings: http://uk3.php.net/manual/en/language.types.string.php#language.types.string.parsing; Magic quotes: http://uk3.php.net/magic_quotes
NickFitz
2009-09-16 17:10:20