PHP simplexml_load_string函数

定义和用法
simplexml_load_string() 函数把 XML 字符串载入对象中。

如果失败,则返回 false。

语法
simplexml_load_file(string,class,options,ns,is_prefix)

在这里插入图片描述

返回值
返回类 SimpleXMLElement 的一个对象,该对象的属性包含 XML 文档中的数据。如果失败,则返回 false。

示例:

<?php
$xmlstring = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
    <to>George</to>
    <from>John</from>
    <heading>Reminder</heading>
    <body>Dont't forget the meeting!</body>
</note>
XML;

$xml = simplexml_load_string($xmlstring);

var_dump($xml);
?>

效果如下:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/zjsfdx/article/details/89376100