我需要我的确认表单中的平均值和精益解决方案。我从服务器XML响应中检索联系人电子邮件地址。也就是说如下:xml新增功能:将儿童数据导入到php变量中
<users>
<User LoginName="test1" Owner="" Alias="" UserType="PAID" ClientType="OBM"
Quota="10737418240" Timezone="GMT+08:00 (CST)" Language="en" DataFile="1"
DataSize="1536" RetainFile="0" RetainSize="0" EnableMSSQL="Y" EnableMSExchange="Y"
EnableOracle="Y" EnableLotusNotes="Y" EnableLotusDomino="Y" EnableMySQL="Y"
EnableInFileDelta="Y" EnableShadowCopy="Y" EnableExchangeMailbox="N"
ExchangeMailboxQuota="0" EnableNASClient="Y" EnableDeltaMerge="Y" EnableMsVm="N"
MsVmQuota="0" EnableVMware="N" VMwareQuota="0" Bandwidth="0" Notes=""
Status="ENABLE" RegistrationDate="1302687743242" SuspendPaidUser="N"
SuspendPaidUserDate="20140503" LastBackupDate="1302699594652" EnableCDP="Y"
EnableShadowProtectBareMetal="Y" EnableWinServer2008BareMetal="Y"
Hostname="123.abc.com">
<Contact Name=""Email="[email protected]"/>
</user>
…
</users>
我就认为我有以下结果:
object(SimpleXMLElement)#7 (1) { [0]=> string(6) "Company" }
object(SimpleXMLElement)#8 (1) { [0]=> string(26) "[email protected]" }
现在我需要那些到变量。我似乎无法实现这一点。我的代码到这里:
$request = "http://$SERVER/obs/api/GetUser.do?
SysUser=$SYSUSER&SysPwd=$SYSPWD&LoginName=$logonname";
// Execute the API Call and place the XML output in an Array variable
$response = simplexml_load_file($request);
// Retrieve the LoginName attribute from the Array
foreach($response->children() as $child) {
foreach($child->attributes() as $data) {
echo var_dump($data);
}
}
任何新手帮助将appriciated。谢谢
弗兰克
你显然已经得到了的SimpleXMLElement持有的电子邮件,那么究竟是什么问题是什么?如何从中获取电子邮件字符串? $ email =(string)$ emailElement; – Gordon 2013-02-15 14:24:49
'echo var_dump'是多余的。 var_dump默认已经输出。 – 2013-02-15 14:30:59