tags:

views:

44

answers:

2

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: 

http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=Xrv&q=sql+into+xml+php&aq=f&oq=&aqi=

longneck
that was so RTFM ....
RageZ
I know how to search in google
Rajasekar
+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
Thanks Very much
Rajasekar
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
@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