473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Search a string inside an xml node

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

%>

Mar 20 '07 #1
1 5591
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

%>

Mar 20 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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 =...
4
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,...
19
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.,...
7
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...
4
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...
5
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...
2
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...
2
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...
0
Debadatta Mishra
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.