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