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 816765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:53:17+00:00 2026-05-15T01:53:17+00:00

How do i select all the text nodes within a specific element node using

  • 0

How do i select all the text nodes within a specific element node using XSL?

Input xml:

 <node1 id="1">
 <node2 id="2">
 <node3 id="3" />
 <node4 id="4">
 <node5 id="5">Text node1</node5>
 <node6 id="6">Text node2</node6>
 </node4>
 </node2>
 <node7 id="7">Text node3
 <node8 id="8">Text node4</node8>
 <node9 id="9">Text node5</node9>
 </node7>
 <node10 id="10">Text node6</node10>
 <node11 id="11">Text node3
 <node12 id="12">Text node4</node12>
 <node13 id="13">Text node5</node13>
 </node11>
 </node1>

Input Param: List of ids of the element nodes whose txt nodes are to be retrieved.

 <nodes><node>4</node><node>7</node><node>10</node></nodes>

Expected Output:

Text node1

Text node2

Text node3

Text node4

Text node5

Text node6

How can this be achieved using XSL? Please share your ideas.

  • 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-15T01:53:18+00:00Added an answer on May 15, 2026 at 1:53 am

    This transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ext="http://exslt.org/common"
     >
     <xsl:output method="text"/>
    
     <xsl:strip-space elements="*"/>
    
     <xsl:param name="pNodes">
        <nodes>
            <node>4</node>
            <node>7</node>
            <node>10</node>
        </nodes>
     </xsl:param>
    
     <xsl:variable name="vNodes"
     select="ext:node-set($pNodes)/*/*"/>
    
     <xsl:template match="/">
       <xsl:for-each select=
          "//*[substring-after(name(),'node')
              = $vNodes
               ]
                //text()">
    
       <xsl:value-of select="concat(.,'&#xA;')"/>
     </xsl:for-each>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <node1 id="1">
        <node2 id="2">
            <node3 id="3" />
            <node4 id="4">
                <node5 id="5">Text node1</node5>
                <node6 id="6">Text node2</node6>
            </node4>
        </node2>
        <node7 id="7">Text node3
            <node8 id="8">Text node4</node8>
            <node9 id="9">Text node5</node9>
        </node7>
        <node10 id="10">Text node6</node10>
        <node11 id="11">Text node3
            <node12 id="12">Text node4</node12>
            <node13 id="13">Text node5</node13>
        </node11>
    </node1>
    

    produces the wanted result:

    Text node1
    Text node2
    Text node3
    Text node4
    Text node5
    Text node6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to select all text in-between following a specific pattern: Sample Text: by
How do i select the preceding nodes of a text node starting from a
What expression would select all text nodes which are: not blank not inside a
I'm trying to find all text nodes on the page using jquery. But no
I would like to select all nodes, that have text in them. In this
I'm creating the MaskedTextBox in WP7.1 In that i want to select all text
When you use a tab key to select a textbox, all text in it
I have an array of variables all containing text. I want to select only
By default, editing an item in a QTable selects all the text within the
I need to arrange the nodes in XHTML in particular predefined order using XSL,

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.