3.2.0

XML build through PHP

hi,


i need to do this : $docXml="<" . $name.">"."</" . $name.">";
but when I do this: print ($docXml), it print nothing.
I think that: ">" is the problem, why????

Sorry, my english is very bad.....


Thanks.
jordi
February 23,
$items = array('name'=>'Tony','age'=>'27');
$docXML = '<?xml version="1.0" encoding="iso-8859-1"?><root>';
foreach ($items as $k => $v) {
     $docXML .= '<'.$k.'>'.$v.'</'.$k.'>';
}
$docXML .= '</root>';

// This is an important line, you need to send a header
header('Content-Type: text/xml');
echo $docXML;
Tony
February 23,

This topic is archived.

See also:


Back to support forum