我将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文件的开头有一些额外的字符。 –