如何使用PHP解析XML數據?我想不僅僅是元素的內容命名我對PHP中解析XML感到困惑
<profile xmlns="mysite.com">
<confirmationNumber>128686132</confirmationNumber>
<merchantRefNum>123456</merchantRefNum>
<customerEmail>[email protected]</customerEmail>
</profile>
我嘗試使用此代碼
$sxe = new SimpleXMLElement($decodedMessage);
echo $sxe->getName() . "\n";
foreach ($sxe->children() as $child)
{
echo $child->getName() . "\n";
}
但我不知道如何選擇一個特定的元素。