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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:31:37+00:00 2026-05-26T21:31:37+00:00

trying to get last from the tag if data of last line is equal

  • 0

trying to get last from the tag if data of last line is equal to personal means then need to populate as 1100 else what ever data presented that it should to be populated
here is my below xml:

    <tag>
    <name>20K</name>
    <value>540211000000100155001
    0100155XXXXXX
    0100156XXXXX
    0100157XXXXXXX
    0100159XXXXXXXX
    personal</value>
</tag>

how to use a logic in xslt can any one guide me

  • 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-26T21:31:38+00:00Added an answer on May 26, 2026 at 9:31 pm

    I. Here is a short and simple way to do this in XSLT 2.0:

    <xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="text"/>
    
     <xsl:template match="/*/value">
         "<xsl:sequence select="tokenize(., '(&#xD;)?&#xA;')[last()]"/>"
     </xsl:template>
     <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    When this transformation is applied to the provided XML document:

    <tag>
        <name>20K</name>
        <value>540211000000100155001
        0100155XXXXXX
        0100156XXXXX
        0100157XXXXXXX
        0100159XXXXXXXX
        personal</value>
    </tag>
    

    the wanted, correct result is produced:

    "    personal"
    

    II. XSLT 1.0 solution

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="value" name="skipLines">
       <xsl:param name="pText" select="."/>
         <xsl:choose>
          <xsl:when test="not(contains($pText, '&#xA;'))">
            "<xsl:value-of select="$pText"/>"
          </xsl:when>
          <xsl:otherwise>
           <xsl:call-template name="skipLines">
             <xsl:with-param name="pText" select=
                 "substring-after($pText, '&#xA;')"/>
           </xsl:call-template>
          </xsl:otherwise>
         </xsl:choose>
     </xsl:template>
     <xsl:template match="text()"/>
    </xsl:stylesheet>
    

    when this transformation is applied to the same XML document (above), again the same correct result is produced:

    "    personal"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this string: tag:domain.com,2012-10-12:feed/channel/id/335 Im trying to get the last digits from this
I am trying to get the last entry from my database based off the
Im trying to get the last string from a URL for example... http://www.mywebsite/blog/this-post I
I'm trying to get the last 50 tweets using a certain hash tag, on
I am trying to get some data off my DB and then trying to
I was trying to get the selected value from the <select> tag in PHP,
In C#, I'm trying to get the last two decimal places of a double
I'm trying to get some information about Azure blob (last modified UTC date time).
So I tried learning LaTeX last night, and I trying to get this template
I'm trying to figure out how to get only the last two files within

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.