0
我使用SimpleXML並希望得到每個不同learner
及其子rater
屬性,我怎麼能解析它變成像一個單獨的:PHP的SimpleXML搶屬性
Learner: John
Rater_1_name: John
Rater_1_email: [email protected]
Rater_1_group: Self
Rater_2_name: Jane
Rater_2_email: [email protected]
Rater_2_group: Manager
Rater_3_name: Nathan
Rater_3_email: [email protected]
Rater_3_group: Peers
// and so on...
代碼解析:
$xml = '
<users>
<learner name="John">
<rater name="John" email="[email protected]" group="Self"></rater>
<rater name="Jane" email="[email protected]" group="Manager"></rater>
<rater name="Nathan" email="[email protected]" group="Peers"></rater>
</learner>
<learner name="Jane">
<rater name="Jane" email="[email protected]" group="Self"></rater>
<rater name="John" email="[email protected]" group="Peers"></rater>
<rater name="Nathan" email="[email protected]" group="Others"></rater>
</learner>
</users>
';
$sxe = new SimpleXMLElement($xml);
echo $sxe->asXML();
謝謝。