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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
Steve EndowMicrosoft 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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.