我將HTML內容解析爲SOAP響應,但無法在客戶端中檢索到它。使用PHP解析SOAP響應?
這是我用於解析SOAP響應的PHP代碼:
$obj = simplexml_load_string(read_file('../soap.xml'));
var_dump($obj->children('http://schemas.xmlsoap.org/soap/envelope/'));
這裏是SOAP響應:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetDetailsResponse xmlns="http://192.168.2.34:180/">
<GetDetailsResult><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
</GetDetailsResult>
</GetDetailsResponse>
</soap:Body>
</soap:Envelope>
它顯示了以下錯誤:
A PHP Error was encountered
Severity: Warning
Message: simplexml_load_string(): Entity: line 1: parser error : XML declaration allowed only at the start of the document
Filename: controller.php
Line Number: 60
A PHP Error was encountered
Severity: Warning
Message: simplexml_load_string():
A PHP Error was encountered
Severity: Warning
Message: simplexml_load_string():^
Filename: controller.php
Line Number: 60
請幫我解析它使用PHP?
它告訴我,我的問題上面給 –
一個PHP錯誤遇到 嚴重的錯誤:警告 消息:simplexml_load_string():實體:第1行:分析器錯誤:XML聲明只允許在文檔的開始 文件名:控制器/ pte.php 行號:60 甲PHP錯誤遇到 嚴重性:警告 消息:simplexml_load_string(): 甲PHP錯誤遇到 嚴重性:警告 消息:simplexml_load_string():^ 文件名:控制器/ pte.php 行號:60 –
我建議兩件事: 1. $ xml ='你的迴應在這裏'; $ obj = simplexml_load_string(read_file($ xml)); var_dump($ obj-> children('http://schemas.xmlsoap.org/soap/envelope/')); 和2: var_dump(readfile('../ soap.xml')); 可能在xml文件的開頭有一些額外的字符。 –