Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6573605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:09:17+00:00 2026-05-25T15:09:17+00:00

How can I get using xslt, node value at X position, without using foreach

  • 0

How can I get using xslt, node value at X position, without using foreach

<items>
<item1>x</item1>
<item2>x</item2>
<item3>x</item3>
</items>

This is explained in programming sense:

<xsl:value-of select="Items/Item[2]"/>

==================================================

Just to little expand question, in the following xml:

<items>
    <about>xyz</about>
    <item1>
       <title>t1</title>
       <body>b1</body>
    </item1>
    <item2>
       <title>t2</title>
       <body>b2</body>
    </item2>
    <item3>
       <title>3</title>
       <body>3</body>
   </item3>
</items>

How can I select second’s item title.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:09:18+00:00Added an answer on May 25, 2026 at 3:09 pm

    Answer to expanded question. You can use the positional value if you select a node-set of the wanted elements:

    <xsl:value-of select="(items//title)[2]"/>
    

    or:

    <xsl:value-of select="(items/*/title)[2]"/>
    

    Note the usage of the parenthesis required to return wanted node-set before selecting by position.


    You can use what you called “in programming sense”. However you need * due to the unknown name of the children elements:

    <xsl:value-of select="items/*[2]"/>
    

    Note that nodes-sets in XSLT are not zero-based. In the way above you are selecting the second item, not the third one.

    You really need position() when you want compare the current position with a number as in:

    <xsl:value-of select="items/*[position()>2]"/>
    

    to select all item with position grater than 2. Other case where position() is indespensible is when position value is a variable of type string:

    <xsl:variable name="pos" select="'2'"/>
    <xsl:value-of select="items/*[position()=$pos]"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question Using XSLT 1.0, given a string with arbitrary characters how can I get
I want to know how we can get record count using reference cursor in
You can get a list of databases using PRAGMA database_list or a list of
We can get the type returned by function in gcc using the typeof operator
In php i can get today date/day by using : $today = date('D, Y-m-d');
I can get the created date, file size etc for a file using the
I'm using SQL Server 2005 and would like to know how I can get
Using the unix dig command, I can get the following MX record: $ dig
Having a really aggravating problem using Managed Metadata in SP2010 where I can get
I'm using VS 2010, and I'm wondering how I can get my c++ program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.