我需要阅读这个文件:
我试过这种方式:$ xml = simplexml_load_file('http://api.crossref.org/works/10.18468/pracs.2016v9n3.p99-119/transform/application/vnd.crossref.unixsd+xml');
echo $ xml-> journal_metadata-> full_title;
我不知道如何获取特定标签的价值。
我需要阅读:Click to see
答案 0 :(得分:-1)
首先从远程服务器加载文件:
$file = @file_get_contents('http://api.crossref.org/works/10.18468/pracs.2016v9n3.p99-119/transform/application/vnd.crossref.unixsd+xml');
if ($file===FALSE)
{
die ("error getting the content of the file");
}
然后,解析xml并使用simplexml:
将其解压缩到一个对象中$o= simplexml_load_string ($file);
最后,您将穿过对象树,直到到达预定目的地
echo "<pre>";
$intended_obj = $o->query_result->body->query->doi_record->crossref->journal->journal_article->doi_data;
print_r($intended_obj->resource);
print_r($intended_obj->collection);
echo "</pre>";
应输出:
SimpleXMLElement Object
(
[0] => https://periodicos.unifap.br/index.php/pracs/article/view/2791
)
SimpleXMLElement Object
(
[@attributes] => Array
(
[property] => crawler-based
)
[item] => SimpleXMLElement Object
(
[@attributes] => Array
(
[crawler] => iParadigms
)
[resource] => https://periodicos.unifap.br/index.php/pracs/article/viewFile/2791/haliadorav9n3.pdf
)
)
祝你好运,