我正在编写一个实时分数和统计网站,我想将我的网站“使用php”链接到一个xml页面,以帮助我尽快获得分数和数据的更新。我尝试了以下PHP代码:
$xml = simplexml_load_file("http://www.iddaa.com.tr/XML/IDDAAMACPROGRAMI/index.htm?iddaadrawid=05.12.2012&iddaadrawide=06.12.2012&foraccess=KSsec654");
print_r($xml);
它给了我以下错误:
Warning: simplexml_load_file() [function.simplexml-load-file]: http://www.iddaa.com.tr/XML/IDDAAMACPROGRAMI/index.htm?iddaadrawid=05.12.2012&iddaadrawide=06.12.2012&foraccess=KSsec654:22: parser error : Opening and ending tag mismatch: link line 10 and head in C:\wamp\www\test\11.php on line 2
注意:我尝试了另一个链接“http://www.goalserve.com/samples/soccer_livescore.xml” 我只能打印该链接的信息。
任何正文都可以帮我正确地将xml文件链接到我的网站吗?
答案 0 :(得分:0)
你可以尝试
$xml = file_get_contents("http://www.iddaa.com.tr/XML/IDDAAMACPROGRAMI/index.htm?iddaadrawid=05.12.2012&iddaadrawide=06.12.2012&foraccess=KSsec654");
$config = array(
'indent' => true,
'clean' => true,
'input-xml' => true,
'output-xml' => true,
'wrap' => false
);
$tidy = new Tidy();
$xml = $tidy->repairString($xml, $config);
$xml = new SimpleXMLElement($xml);
print_r($xml);