我对于结合PHP使用XML表格很新颖。我试图从通过SOAP调用返回给我的XML文件中提取数据。从XML到PHP的特定字段
我的XML正在返回,因为这一点。
注释掉一些细节
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<loginResponse>
<result>
<metadataServerUrl>https://...-api.salesforce.com/service...</metadataServerUrl>
<passwordExpired>false</passwordExpired>
<sandbox>false</sandbox>
<serverUrl>https://...--api.salesforce.com/services/Soap/u/21.0/0...</serverUrl>
<sessionId>....</sessionId>
<userId>....</userId>
<userInfo>
<accessibilityMode>false</accessibilityMode>
<currencySymbol>€</currencySymbol> ... </userInfo>
</result>
</loginResponse>
</soapenv:Body>
</soapenv:Envelope>
所以我试图拉出来的这个会话ID
// UP HERE SOAP CALL --- return data
.......
} else {
$response = curl_exec($soap_do);
curl_close($soap_do);
// print($response); <-- see result XML
// grabbing the sessionid
$xmlresponse = new SimpleXMLElement($response);
$test = $xmlresponse->result->sessionId['value'];
echo $test;
}
这将返回空白,但是当我开始添加LoginResponse和Soapenv(身体和信封),我得到一个关于我想要获得非物件属性的错误。我不确定我在这里做错了什么。
你为什么不使用'的file_get_contents()'? – SaidbakR
没有这样工作,@SaidbakR。我通过卷发发送了一张表格,这是我回复的回复。 – Dorvalla