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

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

WBOY
Release: 2016-06-13 12:18:39
Original
946 people have browsed it

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

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

我如何获取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];
Copy after login
{"status":"failed","result":"未知错误"}

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template