この 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>
suburb_city_postal_codeと attribute_id_status を取得できました。この場合、「アグネス」である都市名を取得するにはどうすればよいですか?
以下の私の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 />";
}
ありがとうございました