PHP의 XML API 인터페이스 데이터 수집

<? PHP의
 헤더 ( '콘텐츠 유형 : 텍스트 / HTML; 문자셋 = 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 배열로, JSON의 SimpleXML을로 변환된다. 
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