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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:11:15+00:00 2026-06-01T06:11:15+00:00

I need to select a node if a condition is matched. I’m totally new

  • 0

I need to select a node if a condition is matched. I’m totally new in XSLT and tried to search for an answer but can’t find a solution that works for me.
I want to select an adres when there is an AddressType = ‘Personal’, if there’s not an AddressType = Personal, check for ‘Second’, if not check for ‘Office’.
A normal If Else.
I tried with and and this could work if only one type of AddressType would exist in the XML file. In my case there can be up too 11 addressTypes (in random order) in the XML file and I can only pass one through.

This looks like my source XML:

<Person>
<address>
<street></street
<number></number>
<City></City>
<AddressType>Personal</AddressType>
</address>
<address>
<street></street
<number></number>
<City></City>
<AddressType>Second</AddressType>
</address>
<address>
<street></street
<number></number>
<City></City>
<AddressType>Office</AddressType>
</address>
</Person>

Any advice? thank you

  • 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-06-01T06:11:17+00:00Added an answer on June 1, 2026 at 6:11 am

    You need to use <xsl:choose>

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:template match="/">
            <xsl:choose>
                <xsl:when test="/Person/address/AddressType='Personal'">
                    <!-- DO Stuff -->
                </xsl:when>
                <xsl:when test="/Person/address/AddressType='Second'">
                    <!-- DO Stuff -->
                </xsl:when>
                <xsl:when test="/Person/address/AddressType='Office'">
                    <!-- DO Stuff -->
                </xsl:when>
                <xsl:otherwise>
                    <!-- Do your else stuff -->
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to find a parent of a select node in
how can i express in xpath a) need select elements which contains specified keyword.
I need to select all columns from two tables, but need to be able
I need to select a node with a id attribute that I only know
I need to select a link node given its url. Using an attribute selector
How can I use XPath to select a node without retrieving all of its
I need help in creating an XSLT style sheet. Namely, I cannot select the
I need to select a node whose name attribute is equal to the current
I need a XSLT function which will return me the xpath to the node
I have found a node, now i need to select sibling text after it:

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.