سؤال

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