We help IT Professionals succeed at work.
Get Started

Yet Another XML XPATH Select Distinct Request

Steve Endow
Steve Endow asked
on
773 Views
Last Modified: 2013-11-11
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".

https://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

Comment
Watch Question
Microsoft MVP
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE