首页 >后端开发 >php教程 >php读取xml节点值,该如何处理

php读取xml节点值,该如何处理

WBOY
WBOY原创
2016-06-13 12:18:39951浏览

php读取xml节点值
获取的XML如下:

<br /><?xml version="1.0" encoding="utf-8"?><br /><string xmlns="SuperMarketService">{"status":"failed","result":"未知错误"}</string><br />

我如何获取string值呢

------解决思路----------------------
header('Content-type: text/html;charset=utf-8');
$s =<<< XML<br /><?xml version="1.0" encoding="utf-8"?><br /><string xmlns="SuperMarketService">{"status":"failed","result":"未知错误"}</string><br />XML;

$x = @simplexml_load_string($s);
echo $x[0];
{"status":"failed","result":"未知错误"}

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn