XSLT - How to select top a to top b
- by user812241
how can I extract the first 2 C-Values ('Baby' and 'Cola') where B is 'RED'. Input instance is:
<Root>
<A>
<B>BLACK</B>
<C>Apple</C>
</A>
<A>
<B>RED</B>
<C>Baby</C>
</A>
<A>
<B>GREEN</B>
<C>Sun</C>
</A>
<A>
<B>RED</B>
<C>Cola</C>
</A>
<A>
<B>RED</B>
<C>Mobile</C>
</A>
</Root>
Output instance must be:
<Root>
<D>Baby</D>
<D>Cola</D>
</Root>
I thought about the combination of for-each and global variables. But in XSLT it is not possible to change the value for a global variable to break the for-each. I have no idea anymore.