【发布时间】:2011-10-19 16:32:18
【问题描述】:
与此问题类似的问题: XPath: select a node based on another node?
对象是根据兄弟节点的值选择一个节点——在本例中是基于Pagetype节点的值的Pagetitle节点。
xpaths:
/dsQueryResponse/Rows/Row/@Title
/dsQueryResponse/Rows/Row/@Pagetype
/dsQueryResponse/Rows/Row/@Pagetitle
这个 xsl 没有返回任何东西:
<xsl:value-of select= "/dsQueryResponse/Rows/Row[Pagetype='Parent']/@Pagetitle" />
示例 xml:
<dsQueryResponse>
<Rows>
<Row>
<Title>1</Title>
<Pagetype>Parent</Pagetype>
<Pagetitle>title of page</Pagetitle>
</Row>
</Rows>
</dsQueryResponse>
目标是返回 Pagetitle 的值,如果它们的 Pagetype 值为“Parent”。
【问题讨论】:
-
请向我们展示输入 XML 的样本并说明您要选择哪些节点。您当前的谓词
[Pagetype='Parent']检查名称为Pagetype且值为Parent的子元素。 -
@Martin 添加了 xml 示例并试图阐明我想要选择的节点。
标签: xml sharepoint xslt xpath predicates