[英]view xml content result from web service response in php
I'm creating php page that connect to a web service and will display the result from the web service, the xml for the web service response is like this: 我正在创建连接到Web服务的php页面,并将显示来自Web服务的结果,Web服务响应的xml如下所示:
<GetUserResponse xmlns="http://the web service">
<GetUserResult>
<xsd:schema>schema</xsd:schema>xml
</GetUserResult>
</GetUserResponse>
I need to know the xml content that I got from the service, and how to deal with it or display it in my page? 我需要知道从服务获得的xml内容,以及如何处理它或将其显示在页面中?
I was able to solve it using: 我能够使用以下方法解决它:
$xml =simplexml_load_string($result); $ xml = simplexml_load_string($ result);
XML File : myxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Gauttam</to>
<from>Kevadia</from>
<heading>My Heading</heading>
<body>Body Content Here!!!!</body>
</note>
TO read in PHP return with Object :
<?php
$xml=simplexml_load_file("myxml.xml");
echo $xml->to . "<br>";
echo $xml->from . "<br>";
echo $xml->heading . "<br>";
echo $xml->body;
// IF XML file having multiple value retrieve it dynamic with array
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.