Yet Another XML XPATH Select Distinct Request

I'm trying to select all of the distinct values for a single node in a large XML file (1MB - 10MB).

I've seen a few examples, but when I try them, they either return a list of all of the nodes (including dups), or I get an error.

I believe this one is close to what I want, but I am getting an error that the XPath "has an invalid token".

I need to select all distinct values for the following node:


Or just:


Here is the XPath that I think is close, but gives me the invalid token error:


In case it matters, I'm using VS 2005 and VB with .NET 2.0.

<?xml version="1.0" encoding="utf-8"?>
<eConnect xmlns:xsi="" xmlns:xsd="">

Open in new window

LVL 18
Steve EndowMicrosoft MVP - Dynamics GPAsked:
Who is Participating?
Steve EndowConnect With a Mentor Microsoft MVP - Dynamics GPAuthor Commented:
Oops, I forgot to include "-sibling".  It should be:

//taPopRcptHdrInsert[not(BACHNUMB  = preceding-sibling::taPopRcptHdrInsert/BACHNUMB)]/BACHNUMB

"preceding" by itself works, but takes alot longer to run.
Steve EndowMicrosoft MVP - Dynamics GPAuthor Commented:
I found my mistake.  

It should be:

//taPopRcptHdrInsert[not(BACHNUMB = preceding::taPopRcptHdrInsert/BACHNUMB)]/BACHNUMB

Takes a while for it to parse, but seems to work.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.