1,PHP解析JSON数据
2,PHP解析XML 数据
$xml_string="<?xml version='1.0'?>
<users>
<user id='123'>
<name>Test</name>
<email>test@jb200.com</name>
</user>
<user id='345'>
<name>News</name>
<email>fnews@jbxue.net</name>
</user>
</users>";
//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 />';
}
如今,json在数据传输上的应用越来越广了,建议大家好好掌握下。