0
我正在使用simplexml_load_string函數來處理xml字符串。PHP XML處理,讀取屬性
以下是xml字符串。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#"
xmlns:ext="http://musicbrainz.org/ns/ext#-2.0">
<artist-list offset="0" count="1422">
<artist ext:score="100" type="Person" id="72c536dc-7137-4477-a521-567eeb840fa8">
<name>Bob Dylan</name>
<sort-name>Dylan, Bob</sort-name>
<gender>male</gender><country>US</country>
<life-span><begin>1941-05-24</begin></life-span>
</artist>
</artist-list>
</metadata>
當函數返回時,我得到下面的數組。 我想要讀取藝術家ext:score =「value」,但它不會被返回,我將如何獲取標籤的這個屬性?
SimpleXMLElement Object
(
[artist-list] => SimpleXMLElement Object
(
[@attributes] => Array
(
[offset] => 0
[count] => 1422
)
[artist] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[type] => Person
[id] => 72c536dc-7137-4477-a521-567eeb840fa8
)
[name] => Bob Dylan
[sort-name] => Dylan, Bob
[gender] => male
[country] => US
[life-span] => SimpleXMLElement Object
(
[begin] => 1941-05-24
)
}
}
}
}
謝謝老兄,你擊中了要害。 – 2012-01-05 18:40:54