小兔网


Deprecated: Required parameter $toggle follows optional parameter $filterGroups in /home/wwwroot/ixiaotu.com/plugins/content/easycontentrestriction/easycontentrestriction.php on line 289

Deprecated: Required parameter $subnum follows optional parameter $n in /home/wwwroot/ixiaotu.com/plugins/content/easycontentrestriction/aop/AopClient.php on line 802

Deprecated: Required parameter $charset follows optional parameter $n in /home/wwwroot/ixiaotu.com/plugins/content/easycontentrestriction/aop/AopClient.php on line 802

Deprecated: Required parameter $length follows optional parameter $start in /home/wwwroot/ixiaotu.com/plugins/content/easycontentrestriction/aop/AopClient.php on line 815

php读取xml文件的方法:

假设myxml.xml文件中的内容如下

    <resource>        <res>this is value</res>        <sound>sound.ogg</sound>    </resource>

首先我们读取这个xml文件的内容

$xml = file_get_contents('myxml.xml');

最重要的一步:解析这个xml文件

$xml_obj = simplexml_load_string($xml);

好了,我们现在有了$xml_obj,我们就可以按照xml文件的结构读取数据了:

//输出 "this is value"echo $xml_obj->res; //输出 "sound.ogg"echo $xml_obj->sound;