【发布时间】:2014-01-29 23:25:47
【问题描述】:
我认为这里还有更多事情要做,但看起来原始 xml 中可用的某些数据在通过我的 soap 调用在 simplexml 元素中设置后对我来说是不可用的。
这是我从 soap 调用中得到的原始信息(通过 soapUI 检索),请特别注意 e_mail 元素。
<GetSubscriberData_ByDrupal_IdResult><![CDATA[
<SubscriberDataRoot>
<SubscriberData>
<city>MEDIA</city>
<state>PA</state>
<zip>19063-4112</zip>
<country>USA</country>
<phone>1231231244</phone>
<e_mail>some_email@somewhere.com</e_mail>
</SubscriberData>
</SubscriberDataRoot>]]>
</GetSubscriberData_ByDrupal_IdResult>
这是我在 SoapClient 调用中生成后 var_dump 的 SimpleXMLElement。
object(SimpleXMLElement)#26 (1) {
["SubscriberData"]=>
object(SimpleXMLElement)#33 (29) {
["city"]=>
string(5) "MEDIA"
["state"]=>
string(2) "PA"
["zip"]=>
string(10) "19063-4112"
["country"]=>
string(3) "USA"
["phone"]=>
string(10) "1231231234"
["e_mail"]=>
object(SimpleXMLElement)#36 (0) {
}
}
}
我可以使用类似于$soap_data->SubscriberData->city 的方式访问大部分数据,但值得注意的是 e_mail 元素不能直接使用,它是另一个 SimpleXMLElement。我试过迭代它,使用asXML,__toString,转换为(string)..
(例如...)
php> var_dump($acct->SubscriberData->e_mail);
object(SimpleXMLElement)#38 (0) {
}
php> var_dump($acct->SubscriberData->e_mail->asXML());
string(17) "<e_mail></e_mail>"
php> var_dump($acct->SubscriberData->e_mail->__toString());
string(0) ""
php> var_dump((string) $acct->SubscriberData->e_mail);
string(0) ""
但我不能像任何其他字符串值元素一样访问它。我希望能够像其他元素一样获取字符串值,例如$email = $acct->SubscriberData->e_mail。提前致谢。
【问题讨论】: