QuickBooksDev Posted December 11, 2012 Share Posted December 11, 2012 We receive an XML document that has several repeating elements. These are optional and can have from 0 to n number. We can only handle 2. How do we just get the first 2 of a set? The for-each gets all which messes up the output that we need. Below is an example of the incoming XML <opts length="4"><opt>Val1</opt><opt>Val2</opt><opt>Val3</opt><opt>Val4</opt></opts> Link to comment Share on other sites More sharing options...
boen_robot Posted December 23, 2012 Share Posted December 23, 2012 Adjust the for-each's XPath so that it only matches the desired number, e.g. <xsl:for-each select="opts/opt[position() <= 2]"> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now