PHP将解析xml变为数组方法


  最近想要做一个插件机制,需要用到xml,在解析xml时候需要转换为数组,特意记录一个此种解析方式

   xml文件

<?xml version="1.0" encoding="UTF-8"?>
<main xmlns="http://www.xiaoetongo.cn" versionCode="1.0">
<controller co="Aritles">
<meth title="测试插件" do="aritle"/>
</controller>
<controller co="Ari">
<meth title="测试插件" do="ar"/>
<meth title="测试插件" do="a"/>
</controller>
<install><![CDATA[]]></install>
<upgrade><![CDATA[]]></upgrade>
</main>

 

<?php

$xml =simplexml_load_string($xmls);
$xmljson= json_encode($xml);
$xml=json_decode($xmljson,true);
dump($xml);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM