?
Solved

xpath in asp -> distinct ??

Posted on 2005-03-18
4
Medium Priority
?
785 Views
Last Modified: 2008-08-21
Hello,

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:
.....
.....
path="/alles/Result/Dossier/AfhPost"
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>")  
next
response.write("</select>")
.....
.....

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.

Greetz,

Svekke
0
Comment
Question by:svekke
[X]
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
4 Comments
 
LVL 26

Accepted Solution

by:
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.

Regards,
Mike Sharp
0
 
LVL 15

Expert Comment

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

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

Expert Comment

by:rdcpro
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.

Regards,
Mike Sharp
0
 

Author Comment

by:svekke
ID: 13589417
Hello,

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

Thnx for the replies!
0

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