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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try one of the 2 options. Data Source=foo\SQLExpress;Initial Catalog=bar;User Id=user;Password=pwd;… May 17, 2026 at 2:26 am
  • Editorial Team
    Editorial Team added an answer Check: Does the file exist (has it been uploaded?) Is… May 17, 2026 at 2:26 am
  • Editorial Team
    Editorial Team added an answer It seems like you are giving too high values to… May 17, 2026 at 2:26 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

How do i select the preceding nodes of a text node starting from a
<script type=text/javascript> $(document).ready(function() { //select all the a tag with name equal to modal
First of all, I'm using sIFR3, r419 (I can't upgrade since I don't have
I have the ID of an element. I want to retrieve all child elements
the empty selector says that: Matches all elements that have no children (including text
I have a XAML document and I want to select all texts with Regex
Is there a very simple way to select all H2 tags on the page,
When looping through elements it thinks the child node is a table, when it
If I have some HTML that looks like this: <div id=text> This is some
I'm having trouble grouping a set of nodes. I've found an article that does

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.