PHPのXML APIインタフェースのデータ収集

<?PHPの
 ヘッダ( 'Content-Typeの:テキスト/ HTML;のcharset = UTF-8' );
 // 1. GET XMLデータ
$ XMLDATA = のfile_get_contents( "HTTP:// URLのAPI" );
 // 2. XML SimpleXMLをオブジェクトに変換される
// $ simplexml_load_string XMLString =($ XMLDATA); 
$ XMLString = simplexml_load_string$ XMLDATA、 'にSimpleXMLElement'、LIBXML_NOCDATA); 
 // 3オブジェクトがJSON形式のSimpleXMLに変換され、次いで、アレイにJSON。
value_arrayを$ = json_decode(json_encode(の$ XMLString)、trueに;) 
 // ますprint_r($ value_arrayを); 
//ダイ(); 
$結果 =$ value_arrayを [ '行' ]。
// 期号
$が期待 = $結果 [ '@attributesを'] [ '期待します' ];
// 号码
$ opencode = $結果 [ '@attributes'] [ 'opencode' ];
// 时间
$ OPENTIME = $結果 [ '@attributes'] [ 'OPENTIME' ];
// ますprint_r($を期待" - " $ opencodeを" - " $ OPENTIMEを。。。。); 
//ダイ(); 
?>

 

おすすめ

転載: www.cnblogs.com/shenjingwa/p/11319222.html