PHP simplexml解析结果需要进行强制类型转换

来源:互联网 发布:ubuntu如何安装eclipse 编辑:程序博客网 时间:2024/06/05 06:10
$xml=simplexml_load_file('city_index.xml');
//print_r ($xml->city_index->location[2]->attributes());

foreach($xml->city_index->location as $location )
{
    print_r ($location->attributes());
    
    $provinceXml=(string)$location->attributes()['province'];    
    $cityXml=(string)$location->attributes()['city'];    
    $countyXml=(string)$location->attributes()['county'];
    
    echo "$countyXml:".$countyXml."<br>";

    if($provinceXml==="广东省" && $cityXml==="广州市" && FALSE!=strstr("从化市",$countyXml))
    {
        echo $location->attributes()['county']."<br>";
        echo $location->brief."<br>";
        echo $location->specialty."<br>";
    }
    /*
    foreach($location->attributes() as $key => $value)
    {
        echo $key,'="',$value,"\"<br>";
    }    
    */
}
0 0
原创粉丝点击