php 读取 xml 文件

 时间:2026-04-30 15:01:12

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

    <resource>

        <res>this is value</res>

        <sound>sound.ogg</sound>

    </resource>

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

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

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

$xml_obj = simplexml_load_string($xml);

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

//输出 "this is value"

echo $xml_obj->res; 

//输出 "sound.ogg"

echo $xml_obj->sound; 

  • window7安装webpack4.8
  • linux教程:[2]Ubuntu安装zookeeper
  • 教你如何使用PHP中的变量
  • Eclipse安装svn插件(离线版)
  • Eclipse安装maven插件配置本地仓库
  • 热门搜索
    红曲米怎么吃 公司理念怎么写 左下腹痛是怎么回事 艺福堂的茶叶怎么样 马自达怎么样 怎么共享文件夹 脚趾甲沟炎怎么治 微商怎么加好友 嚼槟榔脸变大怎么恢复 煎鱼怎么不粘锅