XML XPATH Select distinct elements

Posted on 2008-11-17
Medium Priority
Last Modified: 2013-11-18
Hi Experts,

How do I select (using C# System.XML) the distinct categories using XPATH into an array?

I am thinking that something along the following line should do the trick, however I ain't having much luck:

xmlNodes = xmlDoc.SelectNodes("//MACHINES/CAR/CATEGORY[not(CATEGORY/text()=preceding::node/text())]/text()");

    <CAR name='Toyota'>    
       <DATA>Some Data</DATA>
    <CAR name='Audi'>    
    <CAR name='Mazda'>    
    <CAR name='Nissan'>    
   <CAR name='Nissan'>    
   <CAR name='Nissan'>    

Open in new window

Question by:XPUSR
  • 2
LVL 60

Accepted Solution

Geert Bormans earned 500 total points
ID: 22982596
you are close

Author Comment

ID: 23046849
Perfect. Thanks, j.
LVL 60

Expert Comment

by:Geert Bormans
ID: 23048269

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question