PHP读取ATOM+;XML结构

PHP读取ATOM+;XML结构,php,xml,atom-feed,Php,Xml,Atom Feed,我有一本书 当我把这一行放到浏览器中时,它显示了一个XML结构。 然后我有了我的PHP文件call.PHP: $root = simplexml_load_file('http://api.elsevier.com/content/search/scidir?query=cmm&httpAccept%28application/atom+xml&apiKey=[validApiKey]'); // Saving the whole modified XML to a new fi

我有一本书

当我把这一行放到浏览器中时,它显示了一个
XML
结构。
然后我有了我的
PHP
文件
call.PHP

$root = simplexml_load_file('http://api.elsevier.com/content/search/scidir?query=cmm&httpAccept%28application/atom+xml&apiKey=[validApiKey]');
// Saving the whole modified XML to a new filename
$root->asXml('results.xml');

?>
<?php
header( "Content-Type: application/vnd.ms-excel" );
header( "Content-disposition: attachment; filename=spreadsheet.xls" );// put your file name here
$url = 'updated.xml'; // xml file location with file name
if (file_exists($url)) {
    $xml = simplexml_load_file($url);

    echo 'Title'."\t" . 'Author'."\t" . 'Publisher'."\t" . 'PDF'."\t\n";
    foreach($xml->document as $books)
    {
        echo $books->title."\t" . $books->author."\t" . $books->publisher."\t" . $books->pdf."\n";
    }
}

?>

如果你向我们展示了XML,我们可能还有更多的事情要做……只是编辑了我的问题,添加了一个无效的XML文件。听起来PHP无法获取XML。尝试使用
file\u get\u contents()
并输出/调试返回的内容。
<search-results><opensearch:totalResults>9616259</opensearch:totalResults><opensearch:startIndex>0</opensearch:startIndex><opensearch:itemsPerPage>25</opensearch:itemsPerPage><opensearch:Query role="request" searchTerms="((cmm) OR (information) OR (of) OR (description) OR (level))" startPage="0"/><link ref="self" href="http://api.elsevier.com/content/search/scidir?start=0&count=25&query=%28%28cmm%29+OR+%28information%29+OR+%28of%29+OR+%28description%29+OR+%28level%29%29&httpAccept(application/xml&apiKey=472d9f703a39bf442e9912860bc91f01" type="application/xml"/><link ref="first" href="http://api.elsevier.com/content/search/scidir?start=0&count=25&query=%28%28cmm%29+OR+%28information%29+OR+%28of%29+OR+%28description%29+OR+%28level%29%29&httpAccept(application/xml&apiKey=472d9f703a39bf442e9912860bc91f01" type="application/xml"/><link ref="next" href="http://api.elsevier.com/content/search/scidir?start=25&count=25&query=%28%28cmm%29+OR+%28information%29+OR+%28of%29+OR+%28description%29+OR+%28level%29%29&httpAccept(application/xml&apiKey=472d9f703a39bf442e9912860bc91f01" type="application/xml"/><link ref="last" href="http://api.elsevier.com/content/search/scidir?start=5975&count=25&query=%28%28cmm%29+OR+%28information%29+OR+%28of%29+OR+%28description%29+OR+%28level%29%29&httpAccept(application/xml&apiKey=472d9f703a39bf442e9912860bc91f01" type="application/xml"/><entry><link ref="self" href="http://api.elsevier.com/content/article/pii/S0025775316306674"/><link ref="scidir" href="http://www.sciencedirect.com/science/article/pii/S0025775316306674"/><dc:identifier>DOI:10.1016/j.medcli.2016.11.027</dc:identifier><eid>1-s2.0-S0025775316306674</eid><prism:url>http://api.elsevier.com/content/article/pii/S0025775316306674</prism:url><dc:title>Importancia del anión GAP ante la falta de información clínica: descripción de un caso clínico de intoxicación oral grave por metanol</dc:title><dc:creator>Ana Isabel, Rodríguez Ruitiña</dc:creator><prism:publicationName>Medicina Clínica</prism:publicationName><prism:issn>00257753</prism:issn><prism:volume>148</prism:volume><prism:issueIdentifier>5</prism:issueIdentifier><prism:coverDate>2017-03-03</prism:coverDate><prism:coverDisplayDate>3 March 2017</prism:coverDisplayDate><prism:startingPage>238</prism:startingPage><prism:endingPage>239</prism:endingPage><prism:doi>10.1016/j.medcli.2016.11.027</prism:doi><openaccess>0</openaccess><openaccessArticle>false</openaccessArticle><openArchiveArticle>false</openArchiveArticle><openaccessUserLicense/><pubType>Carta al Editor</pubType><pii>S0025-7753(16)30667-4</pii><authors><author><given-name>Ana Isabel</given-name><surname>Rodríguez Ruitiña</surname></author><author><given-name>José Gregorio</given-name><surname>Zorrilla Riveiro</surname></author><author><given-name>Dolors</given-name><surname>García Pérez</surname></author></authors><prism:teaser/></entry>