[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 789
  • Last Modified:

xpath in asp -> distinct ??

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
svekke
Asked:
svekke
  • 2
1 Solution
 
rdcproCommented:
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
 
dualsoulCommented:
this is easy in XPath 2.0 :))

but Microsoft doesn't want to support it...
0
 
rdcproCommented:
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
 
svekkeAuthor Commented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now