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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:24:32+00:00 2026-06-08T23:24:32+00:00

I am still struggling a little with XPath. Current XML <?xml version="1.0" encoding="utf-8" ?>

  • 0

I am still struggling a little with XPath.

Current XML

<?xml version="1.0" encoding="utf-8" ?>
<data>
    <table_1 dropdown1="Item1"></table_1>
    <listitems key1="Item1" name="" key2="Id2"/>
    <listitems key1="Item1" name="Item A" key2="Id2"/>
    <listitems key1="Item1" name="Item B" key2="Id2"/>
    <listitems key1="Item1" name="" key2="Id4"/>
    <listitems key1="Item1" name="Item A" key2="Id4"/>
    <listitems key1="Item1" name="Item B" key2="Id4"/>
    <listitems key1="Item2" name="" key2="Id6"/>
    <listitems key1="Item2" name="Item C" key2="Id6"/>
    <listitems key1="Item2" name="Item D" key2="Id6"/>
</data>

Current XSL

<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>           

    <xsl:template match="/">
        <html>
            <head>
                <title>Untitled</title>
            </head>
            <body>
                <xsl:for-each select="/data/listitems[@key1=/data/table_1/@dropdown1]">
                    <xsl:value-of select="@name"/>                    
                    <br/>
                </xsl:for-each>
                
            </body>
        </html>
    </xsl:template>

    <xsl:template match="listitems">
        <xsl:value-of select="concat(@name, ' ')" />
    </xsl:template>
</xsl:stylesheet>

Current Result:

enter image description here

  • 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-08T23:24:35+00:00Added an answer on June 8, 2026 at 11:24 pm

    Assuming you consider <listitems> elements with the same name attribute as duplicates, you can use XPath’s preceding-sibling axis to ignore any elements that are duplicates:

    <xsl:for-each select="/data/listitems[@key1=/data/table_1/@dropdown1][not(@name = preceding-sibling::listitems/@name)]">
    

    That means, you select all the items you selected, with the additional restriction that there not be any preceding <listitems> sibling element whose name attribute has the same value as that of the element being tested.

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

Sidebar

Related Questions

This is a rather basic question, however I'm still struggling with it a little.
I'm still new to ASP.NET MVC and I'm struggling a little with the routing.
I'm still struggling with the view-based NSOutlineView in my little Cocoa application. I'm trying
I'm still struggling to find an answer to my question. I want to download
I am trying learn the use of lambda expressions and hence still struggling to
I see there are several posts regarding Cannot set Property and I'm still struggling
I have been struggling with this yesterday whole day, and still couldnt figure it
Still working through JQuery to get data and repopulate portions of a page. Right
still new to XML parsing with the iphone so i have a few questions.
I have a PHP file which produces an Xml sitemap based on data which

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.