标签:
文件名:test.xml
方法一:读取文件到一个字符串,通过解析字符串:
$url = "http://localhost/test/test.xml";
$xmlString=file_get_contents($url);
$xml_array=simplexml_load_string($xmlString);
var_dump($xml_array);
$state = $xml_array->ADDRESS_value->value[4][‘state‘];
$city = $xml_array->ADDRESS_value->value[5][‘city‘];
$address =$xml_array->ADDRESS_value->value[6][‘address‘];
$state = iconv("UTF-8","EUC-JP",$state);
$city = iconv("UTF-8","EUC-JP",$city);
$address =iconv("UTF-8","EUC-JP",$address);
echo ‘$state=‘.$state.‘
‘;
echo ‘$city=‘.$city.‘
‘;
echo ‘$address=‘.$address.‘
‘;
方法二:直接解析xml文件
$xml = simplexml_load_file("http://localhost/test/test.xml")
print_r($xml);
标签: