与此问题类似的问题: XPath: select a node based on another node?
目的是根据兄弟节点的值来选择一个节点——在本例中是基于 Pagetype 节点的值的 Pagetitle 节点。
路径:
/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”。