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