Home  >  Article  >  Backend Development  >  php读取xml节点值,该如何处理

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

WBOY
WBOYOriginal
2016-06-13 12:18:39913browse

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":"未知错误"}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn