在Laravel 5.1中使用Easy RDF

3

我需要在我的Laravel 5.1项目中使用Easy RDF库,但遇到了一些问题。我已经将这个库添加到我的composer.json文件中,安装了它,现在我有了以下代码:

 public function index()
    {
        $foaf = new EasyRdf_Graph("http://biblioteka.wejherowo.pl/dlibra/dlibra/rdf.xml?type=e&id=1589");
        $foaf->load();
        $me = $foaf->primaryTopic();
        dd($me->get('dc:title'));
    }

但是当我尝试显示东西时,我收到有关格式的错误,我需要配置这个库吗?

以下是屏幕截图:

输入图片说明

1个回答

1

由于即使在ctor的第三个参数中使用了格式提示rdfxml,此图形URI仍无法加载,请尝试间接加载:

$file = file_get_contents('http://biblioteka.wejherowo.pl/dlibra/dlibra/rdf.xml?type=e&id=1589');
$parser = new EasyRdf_Parser_RdfXml();
$graph = new EasyRdf_Graph();
$parser->parse($graph, $file, 'rdfxml', null);
print $graph->dump('text');

然而,这并不能回答您关于格式错误的问题。

谢谢!这对我有用。但我还有一个问题。例如,对于此RDF文件:http://biblioteka.wejherowo.pl/dlibra/dlibra/rdf.xml?type=e&id=1589 - 我如何获取此标签的值:<dc:language xml:lang="pl">pol</dc:language>? :) - c00per

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接