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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:52:01+00:00 2026-05-29T03:52:01+00:00

How can i disply the same level element values after if conditon For example

  • 0

How can i disply the same level element values after if conditon

For example

XML

<catalog>
<cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
</cd>
<cd>
    <title>Hide your heart</title>
    <artist>Bonnie Tyler</artist>
    <country>UK</country>
    <company>CBS Records</company>
    <price>9.90</price>
    <year>1988</year>
</cd>
<cd>
    <title>Greatest Hits</title>
    <artist>Dolly Parton</artist>
    <country>USA</country>
    <company>RCA</company>
    <price>9.90</price>
    <year>1982</year>
</cd>

XSLT

<xsl:if test="/catalog/cd/country='UK'">
    <xsl:value-of select="title"/>
    <xsl:value-of select="artist"/>
</xsl:if>

This will not displying the title and artist of UK level elements

I know that one way of solving it is to use for each loop but i am looking for an efficient method

  • 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-29T03:52:02+00:00Added an answer on May 29, 2026 at 3:52 am

    This can be done using only templates:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:template match="/catalog/cd[country='UK']" priority="1">
            <xsl:value-of select="title"/>
            <xsl:value-of select="artist"/>
        </xsl:template>
        <xsl:template match="/catalog/cd">
            <!--  handle non-UK CDs here -->
        </xsl:template>
    </xsl:stylesheet>
    

    There are many other ways — depending on your requirements, of course — to arrange templates to generate your desired output. For example, you might end up with explicit templates for handling title and artist elements (or for explicitly hiding all other children of each cd).

    All of this depends on your particular needs, but the general point I wanted to show here is that you gain a lot of power (and end up with cleaner code) when you properly catch target elements in a template match (instead of ad-hoc conditionals).

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

Sidebar

Related Questions

I want to extend Nodes with the title of the parentnode so I can
Can anyone tell me how I can display a status message like 12 seconds
How i can display all applications icons and name which are installed in device
Possible Duplicate: Is there a tool that can display a SVN repository visually (
Examotion has a player that can display the image for svg files as a
Is there any firefox addon which can display my asp.net page viewstate size.... Any
I'm wondering how I can display the recently created nodes by a user on
With LINQ to SQL in a ASP.NET MVC website I can display objects (records)
I want to format a date object so that I can display strings such
Does a smart textbox control (WinForms) exists that can display a path depending on

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.