最近想要做一個插件機制,需要用到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);