从具有特定属性值的节点开始查找具有特定属性值的所有子节点的 xpath 查询是什么?
这与我之前发布的有关解析 rdf xml 文件的问题有关 - 我以为我已经解决了它,但还没有完全解决。
例如,我试图解析并获取所有 rdf:about 属性值。我这个工作正常。我需要添加以下条件 - 解析需要在找到特定的 rdf:about 值后开始。
我正在 PHP 中工作,并使用 DomDocument
并使用以下 xpath 查询:
$xpath->query('//@rdf:about');
它可以很好地找到所有 rdf:about
属性。
我需要扩展它以仅查找 rdf:about 属性等于某项的节点后面的那些属性。
如何?
What would be the xpath query to find all child nodes with a specific attribute value, but starting from a node with a specific attribute value?
This is kind of related to a question I posted earlier about parsing an rdf xml file - I thought I had solved it but not quite yet.
For example, I am trying to parse and grab all of the rdf:about
attribute values. I have this working fine. I need to add the following condition though - parsing needs to start after a specific rdf:about
value is found.
I am working in PHP and and using DomDocument
and am using the following xpath query:
$xpath->query('//@rdf:about');
It is finding all rdf:about
attributes fine.
I need to extend this to only find those attributes that come after the node whose rdf:about
attribute is equal to something.
How?
发布评论
评论(2)
使用示例脚本,输出以以下内容开头/结尾的 URL:
With your sample script, outputs URLs starting/ending with:
嗨,克里斯,抱歉,但这对我来说不太有效。如果您运行我的以下代码:
您应该获得 sioc 本体中的元素列表。问题是前 9 个节点实际上并不是本体的一部分,所以我想忽略它们并从具有 'http://rdfs.org/sioc/ns#' 作为 rdf:about 属性的值。
通过包含您的 xpath 查询,我什么也没得到。
HI Chris sorry but that isnt quite working for me. If you run my following code:
You should get a list of elements in the sioc ontology. The problem is that the first 9 are not actually part of the ontology and so I want to ignore them and start on the 10th node which has 'http://rdfs.org/sioc/ns#' as its value for the rdf:about attribute.
By including your xpath query i get nothing back at all.