XPath可以跨XML的两个子树进行外键查找吗?

说我有以下XML …
<root>
  <base>
    <tent key="1" color="red"/>
    <tent key="2" color="yellow"/>
    <tent key="3" color="blue"/>
  </base>
  <bucket>
    <tent key="1"/>
    <tent key="3"/>
  </bucket>
</root>

… XPath会返回什么,“桶”包含“红色”和“蓝色”?

如果您使用的是XSLT,我建议您设置一个密钥:
<xsl:key name="tents" match="base/tent" use="@key" />

然后你可以得到< tent>在< base>内使用特定密钥

key('tents',$id)

那你可以做

key('tents',/root/bucket/tent/@key)/@color

或者,如果$bucket是特定的< bucket>元件,

key('tents',$bucket/tent/@key)/@color

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念