1、使用php的dom对象读取
示例。
//echo $id;
$sql="select city_api from ".$GLOBALS ['ecs']->table ( 'groupon_site' )." where site_id=".$cid;
$api=$GLOBALS['db']->getOne($sql);
$xml=file_get_contents($api);
$doc=new DOMDocument();
$doc->loadXML($xml);
switch($cid)
{
case 3:
$citys=$doc->getElementsByTagName('city');
foreach($citys as $city)
{
$city_names=$city->getElementsByTagName('name');
echo $city_names->item(0)->nodeValue;
}
break;
}
2、采用php函数simplexml_load_string也可读取。
正文完