我正在尝试在 QueryPath 库中获取我的自定义元素。但是 QueryPath 不起作用。谁能帮助我如何在 QueryPath 中做到这一点?请参阅下面的示例代码;
<plugin:text path="filename" />
此外,我还详细检查了 PhpSimpleDom 库。虽然它对我有用。但它不提供对 css 选择器等的全面支持。我在 PhpSimpleDom 中也遇到了一个非常糟糕的内存问题。
谁能帮我在 QueryPath 中获取上述元素?
谢谢斯马克
我正在尝试在 QueryPath 库中获取我的自定义元素。但是 QueryPath 不起作用。谁能帮助我如何在 QueryPath 中做到这一点?请参阅下面的示例代码;
<plugin:text path="filename" />
此外,我还详细检查了 PhpSimpleDom 库。虽然它对我有用。但它不提供对 css 选择器等的全面支持。我在 PhpSimpleDom 中也遇到了一个非常糟糕的内存问题。
谁能帮我在 QueryPath 中获取上述元素?
谢谢斯马克
来自https://github.com/pode/reiseplanlegger/blob/master/api/dbpedia.php:
rdf:
<rdf:RDF><rdf:Description rdf:about="http://dbpedia.org/resource/John_Frandsen_(footballer)"><dbpprop:placeOfBirth rdf:resource="http://dbpedia.org/resource/Denmark"/><dbpedia-owl:birthPlace rdf:resource="http://dbpedia.org/resource/Denmark"/></rdf:Description>/rdf:RDF>
代码:
// Fetch the URL and select all rdf:Description elements.
// (Note that | is the CSS 3 equiv of colons for namespacing.)
// To add the context, we pass it in as an option to QueryPath.
$qp = qp($url, 'rdf|Description', array('context' => $cxt));
[...]
// Here, we use rdf|* to select all elements in the RDF namespace.
$qp->top()->find('rdf|about');
(注意 | 是 CSS 3 中命名空间冒号的等价物。)