源XML是:simplexml_load_string獲取屬性
<attributeGroup id="999" name="Information">
<attribute id="123" name="Manufacturer">Apple</attribute>
<attribute id="456" name="Model">iPhone</attribute>
</attributeGroup>
代碼:
$xml = simplexml_load_string($xml);
print_r($xml);
輸出:
SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 999
[name] => Information
)
[attribute] => Array
(
[0] => Apple
[1] => iPhone
)
)
我如何也可爲g等它返回標籤attribute id
和name
?
謝謝。這工作,但我怎麼也可以在同一個數組中獲得文本值?所以它會顯示ID,名稱和文本值。 – user2029890
更新了您的請求的代碼 – abeyaz