我正在尝试从此 XML 输出中检索数据:
<string xmlns="http://tempuri.org/soap/AustralianTourismWebService">
<?xml version="1.0" encoding="utf-16" ?><atdw_data_results><area area_id="9000672" area_name="Gippsland area" attribute_id_area_type="LOCAL">
<city suburb_city_postal_code="3962" attribute_id_status="ACTIVE" geocode_gda_latitude="-38.670501000" geocode_gda_longitude="146.395343000" attribute_id_geocode_proj_sys="GDA94">Agnes</city>
我能够检索郊区_city_postal_code 和attribute_id_status。在这种情况下,如何检索“Agnes”的城市名称?
请在下面查看我的 PHP 代码:
$result = simplexml_load_string(trim(html_entity_decode($result)), 'SimpleXMLElement');
/** Instantiate Loop */
foreach ($result->area->city as $entry) {
$pna = htmlspecialchars_decode($entry->attributes()->suburb_city_postal_code, ENT_QUOTES);
$pna = str_replace("'", "''", $pna);
$str = htmlspecialchars_decode($entry->attributes()->attribute_id_status, ENT_QUOTES);
$str = str_replace("'", "''", $str);
echo $pna. "<br />";
echo $str . "<br />";
}
谢谢