/*
<?xml version='1.0' encoding='utf-8' ?>
<root cityid="0" classid="0" placeid="0" yy="0" mm="0" pg="1" ps教程="20" maxPage="1" num="1" serverIP="58.57.65.195">
<expo ID="3889" cityid="53" city="北京" classid="0" classname="建筑/装潢/五金" place="中国国际展览中心" placeid="0" tm1="2010-6-3" tm2="2010-6-5" title="20会" Address="北
里河路13号">
<![CDATA[2010北京第十五届中件系列]]>
</expo>
</root>
*/
<?php
$url = "http://www.111cn.net/xml.xml";
$dom = new DOMDocument();
$dom->load($url);
$root = $dom->documentElement;
$arr=array();
foreach ($root->childNodes as $item)
{
if($item->hasChildNodes())
{
$tmp=array();
foreach($item->childNodes as $one)
{
$tmp[$one->tagName]=$one->nodeValue;
}
$arr[$item->tagName]=$tmp;
}
}
$jsonStr = json_encode($arr);
var_dump($jsonStr);
/*
*/
?>