1、先用json_decode转化为数组。再转化为xml

<?php

header('content-type:text/xml;charset=utf-8');

$url = "http://zphteach.com/zph/8wei/json/json.php";

$str = file_get_contents($url);

$arr = json_decode($str,true);

echo "<?xml  version='1.0' encoding='utf-8' ?>";

echo "<tell>";

foreach($arr as $v)

{

echo "<name>";

echo "<message><![CDATA[$v[name]]]></message>";

echo "<sex>{$v['sex']}</sex>";

echo "</name>";

}

echo "</tell>";

?>