php解析JSON与XML的小例子,供大家学习参考。
1、解析JSON数据
2、解析XML 数据
I)、xml文件
II)、解析xml的代码
<?php
//load the xml string using simplexml
$xml = simplexml_load_string($xml_string);
//loop through the each node of user
foreach ($xml->user as $user)
{
//access attribute
echo $user['id'], ' ';
//subnodes are accessed by -> operator
echo $user->name, ' ';
echo $user->email, '<br />';
}
?>