我對於結合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