Hello, I am looking for a way to do a string search inside an xml.
Basically, I work for a company that wants to export an XML file from
and excel sheet and then have that data be presented on the web. Part
of the presentation is that they want to be able to "search" for their
favorite dealers. So, this will be a string search.
The difficulty is, we dont have .NET, we dont have a SQL server -- all
I can use is ASP classic.
So, I can read/parse the XML and I can search for static things like
zip codes and products (products from a drop down list that dont
change) using simple "if" statements however, when it comes to a
string, unless the user enters it EXACTLY how its spelled an
punctuated in the XML, it wont return the match (of course).
I've read about a lot of functionality that .NET offers for string
search, but I havent yet found anything for classic.
The code I am going to post works and will eventually become the
actual engine, but for now the variables are for people - name, color,
number.
So the million dollar question is, if I wanted to add another
dimension to my array that had a string where I wanted to pick up on
keywords - lets say one word in up to 230 characters, how on earth
would I create a function to make it searchable (search inside of a
string)
thanks guys
(here is the code)
<%
Dim xdoc
Set xdoc=Server.CreateObject("Microsoft.XMLDOM")
xdoc.async=false
xdoc.load("/newtext.xml")
if xdoc.parseError.errorcode<>0 then
response.write "there was obviously an error"
else
response.write "Things worked"
end if
dim theLength
theLength = xdoc.SelectNodes("/test/person").length
dim counter
counter = 0
dim theArray()
ReDim theArray(theLength, 2)
For Each elemPerson in xdoc.SelectNodes("/test/person")
For Each elem in elemPerson.SelectNodes("*")
theArray(counter,0)= elemPerson.childNodes(0).text
theArray(counter,1)= elemPerson.childNodes(1).text
theArray(counter,2)= elemPerson.childNodes(2).text
Next
counter = counter + 1
Next
dim real
real = theLength - 1
dim rowcounter
rowcounter = 1
For i=0 to real
dim personName
personName = theArray(i, 0)
dim personColor
personColor = theArray(i, 1)
dim personNumber
personNumber = theArray(i, 2)
dim search_name
search_name = "Jason"
dim search_color
search_color = "blue"
dim search_number
search_number = "16"
dim color
color = " class='even'"
if rowcounter MOD 2 <0 then
color = " class='odd'"
end if
if (personName = search_name or personColor = search_color) then
response.write "<tr" & color &">"
response.write "<td>" & personName & "</td>"
response.write "<td>" & personColor & "</td>"
response.write "<td>" & personNumber & "</td>"
response.write "<td>" & rowcounter & "</td>"
response.write "</tr>"
rowcounter = rowcounter + 1
end if
Next
%> 1 5587
this may help http://www.1aspstreet.com/vb/scripts...=6367&lngWId=4
<le*****@gmail.comwrote in message news:11**********************@l77g2000hsb.googlegr oups.com...
Hello, I am looking for a way to do a string search inside an xml.
Basically, I work for a company that wants to export an XML file from
and excel sheet and then have that data be presented on the web. Part
of the presentation is that they want to be able to "search" for their
favorite dealers. So, this will be a string search.
The difficulty is, we dont have .NET, we dont have a SQL server -- all
I can use is ASP classic.
So, I can read/parse the XML and I can search for static things like
zip codes and products (products from a drop down list that dont
change) using simple "if" statements however, when it comes to a
string, unless the user enters it EXACTLY how its spelled an
punctuated in the XML, it wont return the match (of course).
I've read about a lot of functionality that .NET offers for string
search, but I havent yet found anything for classic.
The code I am going to post works and will eventually become the
actual engine, but for now the variables are for people - name, color,
number.
So the million dollar question is, if I wanted to add another
dimension to my array that had a string where I wanted to pick up on
keywords - lets say one word in up to 230 characters, how on earth
would I create a function to make it searchable (search inside of a
string)
thanks guys
(here is the code)
<%
Dim xdoc
Set xdoc=Server.CreateObject("Microsoft.XMLDOM")
xdoc.async=false
xdoc.load("/newtext.xml")
if xdoc.parseError.errorcode<>0 then
response.write "there was obviously an error"
else
response.write "Things worked"
end if
dim theLength
theLength = xdoc.SelectNodes("/test/person").length
dim counter
counter = 0
dim theArray()
ReDim theArray(theLength, 2)
For Each elemPerson in xdoc.SelectNodes("/test/person")
For Each elem in elemPerson.SelectNodes("*")
theArray(counter,0)= elemPerson.childNodes(0).text
theArray(counter,1)= elemPerson.childNodes(1).text
theArray(counter,2)= elemPerson.childNodes(2).text
Next
counter = counter + 1
Next
dim real
real = theLength - 1
dim rowcounter
rowcounter = 1
For i=0 to real
dim personName
personName = theArray(i, 0)
dim personColor
personColor = theArray(i, 1)
dim personNumber
personNumber = theArray(i, 2)
dim search_name
search_name = "Jason"
dim search_color
search_color = "blue"
dim search_number
search_number = "16"
dim color
color = " class='even'"
if rowcounter MOD 2 <0 then
color = " class='odd'"
end if
if (personName = search_name or personColor = search_color) then
response.write "<tr" & color &">"
response.write "<td>" & personName & "</td>"
response.write "<td>" & personColor & "</td>"
response.write "<td>" & personNumber & "</td>"
response.write "<td>" & rowcounter & "</td>"
response.write "</tr>"
rowcounter = rowcounter + 1
end if
Next
%> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Lee |
last post by:
Hi all,
I'm trying to use a Java written search code to traverse a DOM
hierarchy.
I'm mainy using code that I obtained from the Sun website. Basically,
in
main(), I have
Element rootElement =...
|
by: Tarique Jawed |
last post by:
Alright I needed some help regarding a removal of a binary search
tree. Yes its for a class, and yes I have tried working on it on my
own, so no patronizing please. I have most of the code working,...
|
by: RAJASEKHAR KONDABALA |
last post by:
Hi,
Does anybody know what the fastest way is to "search for a value in a
singly-linked list from its tail" as oposed to its head?
I am talking about a non-circular singly-linked list, i.e.,...
|
by: Bonj |
last post by:
In making a ternary search tree to identify as fast as possible the type of
word passed in to the algorithm, for instance sp_help -> 1 (procedures),
select -> 2 (keywords), sysobjects -> 3 (system...
|
by: BenCoo |
last post by:
Hello,
In a Binary Search Tree I get the error : Object must be of type String
if I run the form only with the "Dim bstLidnummer As New BinarySearchTree"
it works fine.
Thanks for any...
|
by: foolproofplan |
last post by:
Hey everyone. I am running into a problem with unique ids that need to
be compared in two xml files. The actual object name is represented
with its unique id later in the xml file, so i need to do...
|
by: Bart Kastermans |
last post by:
Summary: can't verify big O claim, how to properly time this?
On Jun 15, 2:34 pm, "Terry Reedy" <tjre...@udel.eduwrote:
Thanks for the idea. I would expect the separation to lead to
somewhat...
|
by: slizorn |
last post by:
hi guys,
i need to make a tree traversal algorithm that would help me search the tree..
creating a method to search a tree to find the position of node and to return its pointer value
basically i...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |