开发者

XSL get the element if the element's name AND its attribute equals certain value

How do I translate the below code into a xsl-compilable form?

What I wanted: return the element with the element name == CT AND the CT's attribute == 'person'.

The xsl I tried (but failed):

<xsl:if 开发者_StackOverflowtest="CT and @Name='person'">

Google keywords are not being very helpful when "And" is involved...

Thanks.


Appropriate XPath: <xsl:value-of select="CT[@Name = 'person']" />

Supposed XML:

<root>
    <CT Name="a">A</CT>
    <CT Name="person">Person</CT>
</root>

XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
        <xsl:value-of select="//CT[@Name = 'person']" />
    </xsl:template>
</xsl:stylesheet>

Result: Person

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜