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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:39:04+00:00 2026-06-09T00:39:04+00:00

I am using XSLT to select and loop through objects with a certain parentID,

  • 0

I am using XSLT to select and loop through objects with a certain parentID, this is working fine. What I then need to do is check the ID of each selected element of the XML against a value.

Here is my code:

XSL:

<xsl:for-each select="categories/category[@parentId='1333']">
    <xsl:choose>
       <xsl:when test="id='1349'">Yes</xsl:when>
       <xsl:otherwise>No</xsl:otherwise>
    </xsl:choose>
</xsl:for-each>

Here is an example XML block:

 <categories>
    <category !!!!THIS IS THE ID I WANT!!!!! id="1348" parentId="1333">
      <name>Name</name>  
      <description>Desc</description>  
      <path>/test/test/testing</path> 
    <category id="1349" parentId="1333">
      <name>Name</name>  
      <description>Desc</description>  
      <path>/test/test/testing</path> 
    </category>  
    <category id="1352" parentId="1333">
      <name>Name</name>  
      <description>Desc</description>  
      <path>/test/test/testing</path> 
    </category>  
    <category id="1370" parentId="1333">
      <name>Name</name>  
      <description>Desc</description>  
      <path>/test/test/testing</path> 
    </category>  
  </categories> 
  • 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-09T00:39:06+00:00Added an answer on June 9, 2026 at 12:39 am

    I think it’s simply that you’re not checking for the attribute correctly.

    Change…

    <xsl:when test="id='1349'"> 
    

    To (note the extra @ which means it’s an attribute name rather than an element name)…

    <xsl:when test="@id='1349'">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using xslt/xpath, I need to be able to select the two elements which have
I have the following xml and I need to sort this xml using XSLT
Using XPath 1.0 and XSLT 1.0 I need to select direct parents of mixed
I'm using XSLT 1.0 an want to transform an XML file. It works fine
I'm using XSLT and need to generate the doctype dynamically in the transformed output,
Pretty green on XSLT and one of the systems I'm working on is using
How can I using XSLT, select only some xml tags from my input xml
I have a combo box set inside a xslt using the following code <select
I am trying to write a loop using XSLT so that it automatically groups
Using XSLT and XPath 1.0, I have a string I want to escape for

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.