<function name="getMemberInfo">
<component name="people">
<property name="ppl_firstname">
<![CDATA[ Jamie ]]>
</property>
</component>
</function>
我試圖檢索ppl_firstname。以上顯示的XML是已由API url解析的代碼的一部分。如何在PHP中使用數組獲取值元素[@attributes]
我用捲曲,以便獲得url內容
$url=""
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url); // get the url contents
$data = curl_exec($ch); // execute curl request
curl_close($ch);
然後我已經把數據在陣列
$xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);
$xmlJson = json_encode($xml);
$xmlArr = json_decode($xmlJson, 1); // Returns associative array
,其輸出是這樣的:
Array ([@attributes] =>
Array ([name] => getMemberInfo) [component] =>
Array ([0] =>
Array ([@attributes] =>
Array ([name] => people) [property] =>
Array ([0] => Jamie [1])
)
)
)
能
人告訴我如何找回名字。在此先感謝
什麼名字? 'Jamie'? 'people'? 'memberInfo'? –
謝謝@u_mulder我需要屬性值<![CDATA [Jamie]]> –