So my XSL questions seem to have no end.

let us say i have the following xml:

<root>
    <dates>
        <date value="20131214" a="one"></date>
        <date value="20131224" a="two"></date>
    </dates>
</root>

Now what i want is to select the value attribute by the a attribute value, so let's say i want the value of a date where it's a value equals one.

What is the best way to achieve this?

有帮助吗?

解决方案

It rather depends on your current context. If you are at the still at the top-level root node ("/"), then:

<xsl:value-of select="root/dates/date[@a='one']/@value"/>

will do.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top