Php 如何读取此xml?
你能帮我吗 我需要阅读此文件: 我试着这样做: $xml=simplexml\u加载\u文件 echo$xml->journal\u metadata->full\u title 我不知道如何获取特定标记的值Php 如何读取此xml?,php,xml,Php,Xml,你能帮我吗 我需要阅读此文件: 我试着这样做: $xml=simplexml\u加载\u文件 echo$xml->journal\u metadata->full\u title 我不知道如何获取特定标记的值 我需要阅读以下内容:首先从远程服务器加载文件: $file = @file_get_contents('http://api.crossref.org/works/10.18468/pracs.2016v9n3.p99-119/transform/application/vnd.cross
我需要阅读以下内容:首先从远程服务器加载文件:
$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>";
祝你好运,但它不起作用,它只是对你所遇到的具体问题的一个简短描述……不,这样没有人能帮助你完成你的工作。。。你有任何代码有问题吗?你试过什么?你至少用谷歌搜索过xml解析器php吗?欢迎来到堆栈溢出。我们不会去其他站点查看您的要求,我们也无法帮助您了解为什么我们看不到的代码对您不起作用。当你在做这件事的时候,看看,然后回来,在你的帖子里,把相关的细节包括在你的问题里。
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
)
)