具体如下:
ETO; $jsonstr='{ "tools": [ { "name":"css format" , "site":"http://tools.jb51.net/code/css" }, { "name":"json format" , "site":"http://tools.jb51.net/code/json" }, { "name":"pwd check" , "site":"http://tools.jb51.net/password/my_password_safe" } ] }'; if(xml_parser($xmlstr)){ echo "\$xmlstr是xml格式数据"; }else{ echo "\$xmlstr不是xml格式数据"; } echo " Jack Herrington PHP Hacks O'Reilly Jack Herrington Podcasting Hacks O'Reilly XML数据 tools.jb51.net
"; if(xml_parser($jsonstr)){ echo "\$jsonstr是xml格式数据"; }else{ echo "\$jsonstr不是xml格式数据"; } ?>
运行结果:
$xmlstr是xml格式数据 $jsonstr不是xml格式数据