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".

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/XML/Q_23913007.html?sfQueryTermInfo=1+distinct+node+xml

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

eConnect/POPReceivingsType/taPopRcptHdrInsert/BACHNUMB

Or just:

//taPopRcptHdrInsert/BACHNUMB


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

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


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="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<POPReceivingsType>
		<taPopRcptLineInsert_Items>
			<taPopRcptLineInsert>
				<POPTYPE>3</POPTYPE>
				<POPRCTNM>4132861-3318462</POPRCTNM>
				<ITEMNMBR>850-110575</ITEMNMBR>
				<VENDORID>GPNBCU01</VENDORID>
				<VNDITNUM>850-110575</VNDITNUM>
				<UNITCOST>3.90</UNITCOST>
				<EXTDCOST>3.90</EXTDCOST>
				<QTYSHPPD>1</QTYSHPPD>
				<QTYINVCD>1</QTYINVCD>
				<LOCNCODE>DROPSHIP</LOCNCODE>
			</taPopRcptLineInsert>
		</taPopRcptLineInsert_Items>
		<taPopRcptHdrInsert>
				<POPRCTNM>4132861-3318462</POPRCTNM>
				<POPTYPE>3</POPTYPE>
				<VNDDOCNM>4132861-3318462</VNDDOCNM>
				<receiptdate>04/02/2010</receiptdate>
				<BACHNUMB>CON2010-04-0111</BACHNUMB>
				<VENDORID>GPNBCU01</VENDORID>
				<SUBTOTAL>3.90</SUBTOTAL>
				<CREATEDIST>1</CREATEDIST>
		</taPopRcptHdrInsert>

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

x
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.
0
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.
0

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
XML

From novice to tech pro — start learning today.