希望有人能帮我用PHP成功解析XML吗?那是我的问题。我在线上找回了XML,但是PHP没有解析它。
PHP-SOAP / 5.2.17和PHP-SOAP / 5.1.6都没有在PHP 5.3上尝试过。
<?PHP
echo "<html><body>\n";
echo "starting<br>\n";
echo "<pre>\n";
$wsdl = "http://192.168.16.7/api/soap/softswitch.wsdl";
ini_set("soap.wsdl_cache_enabled", "0"); // disable WSDL cache
$client = new SoapClient($wsdl, array('trace'=>true, 'exceptions'=>true));
try {
$response = $client->get_queue_destinations($_REQUEST['username'],
$_REQUEST['password'], $_REQUEST['queue']);
# echo "$response";
print_r($response);
# var_dump($response);
$x = serialize($client->__getLastResponse());
print_r($x);
#$xml = simplexml_load_string($client->__getLastResponse());
#print_r($xml);
# print "Request: \n".htmlentities($client->__getLastRequest()) ."\n";
# print "Response: \n".htmlentities($client->__getLastResponse())."\n";
# echo "</pre>\n";
} catch (Exception $e) {
echo "<pre>\n";
echo "Caught Exception: " . $e->getMessage() . "\n";
// Show the actual XML sent and received
print "Request: \n".$client->__getLastRequest() ."\n";
print "Response: \n".$client->__getLastResponse()."\n";
echo "</pre>\n";
}
echo "</pre>\n";
echo "finished\n";
echo "</body><html>\n";
?>
答案 0 :(得分:0)
&#34;序列化函数不能用于xml解析&#34;
#$xml = simplexml_load_string($client->__getLastResponse());
#print_r($xml);
简单XML是一个对象,它不能以这种方式成为print_r。