xpath in asp -> distinct ??

Posted on 2005-03-18
Medium Priority
Last Modified: 2008-08-21

I have a problem with xpath within an asp page.
I have this asp page that receives a string with xml layout.
To handle this xml string, I use XPath (within asp). A part of the code is like this:
set nodes=xmlDoc.selectNodes(path)
response.write("<select name=postcode>")
response.write("<option value=0> </option>")
for each x in nodes
   response.write("<option value=" & x.text & ">" & x.text & "</option>")  

This part of code gathers all the zipcodes from the xml and displays them in a dropdown box.
Until this point, everything goes well.
But some of the zipcodes are displayed more than once (because they are more than once in the xmlfile).
I was wondering if I can use a sort of distinct to display them only once? I can't get it to work. I know there is something like fn:distinct-values(), but this doesn't work in asp right?

Does anybody know a possibility?
If you want some more information, don't hesitate to ask.

Thanks in advance.


Question by:svekke
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 26

Accepted Solution

rdcpro earned 2000 total points
ID: 13576820
create an dictionary object/associative array (or a simple array of strings) and iterate over each zipcode.  As you iterate, examine the zipcode value to see if it already exists in the array.  If not, then add it.  Then use the array to build your HTML.

This is easy in XSLT, though.

Mike Sharp
LVL 15

Expert Comment

ID: 13578544
this is easy in XPath 2.0 :))

but Microsoft doesn't want to support it...
LVL 26

Expert Comment

ID: 13578966
They have said they will support it when it reaches recommendation status.  I think they got a lot of grief over their support of the old XSL working draft in IE 5 and  5.5.  In fact, it still causes problems today.  While I wish they had a "beta" or web release version of the parser (call it 5.1), I can understand their reluctance.

Mike Sharp

Author Comment

ID: 13589417

Using an array was my second opinion. I was just wondering if I couldn't do it easier.

Thnx for the replies!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question