473,398 Members | 2,380 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,398 software developers and data experts.

Searching xml file for multiple searchstrings

Hi,
I want to search an xml file for particular searchstrings and also
based on the date i.e. all items containing the date -----prior to the
specified date, or ----on that date or ----- after the specified date.

Also i want to search throught he xml nodes for more than one search string.

for e.g.
suppose i have an xml file
<books>
<book>
<title> abcdef </title>
<author> sdkfj </author>
<pubdate> 2004/12/02 </pubdate>
</book>
<book>
<title> kjdfj </title>
<author> kdjfk </author>
<pubdate> 2003/09/31 </pubdate>
</book>
<book>
<title> kjdfj </title>
<author> kdjfk </author>
<pubdate> 2001/02/21 </pubdate>
</book>
</books>

Now my web page can accept different search criterias.
like SEARCH FOR

searchtitle = "abc"
searchauthor = "kjk"
searchdate = before/after/on(dropdownlist) 2001/02/21

How can i specify the XPath expression for each of these search conditions.

uptil now what i have been able to do is i am able to search the xml nodes
based on one particular search string
i.e. in the following way

string matchFrom = "descendant::book[contains(title, '" +searchtitle +
"')]";
XmlNodeList nodelist = doc.SelectNodes(matchFrom);

How can i perform the search based on multiple search criterias and how can
i comapre for the date value.

Please help,
Any advice would be helpful,

regards
Smita.

Nov 12 '05 #1
1 2191

"smita" <sm***@rarefind.com> wrote in message
news:eF***************@TK2MSFTNGP11.phx.gbl...
Hi,
I want to search an xml file for particular searchstrings and also
based on the date i.e. all items containing the date -----prior to the
specified date, or ----on that date or ----- after the specified date.

Also i want to search throught he xml nodes for more than one search string.
for e.g.
suppose i have an xml file
<books>
<book>
<title> abcdef </title>
<author> sdkfj </author>
<pubdate> 2004/12/02 </pubdate>
</book>
<book>
<title> kjdfj </title>
<author> kdjfk </author>
<pubdate> 2003/09/31 </pubdate>
</book>
<book>
<title> kjdfj </title>
<author> kdjfk </author>
<pubdate> 2001/02/21 </pubdate>
</book>
</books>

Now my web page can accept different search criterias.
like SEARCH FOR

searchtitle = "abc"
searchauthor = "kjk"
searchdate = before/after/on(dropdownlist) 2001/02/21

How can i specify the XPath expression for each of these search conditions.
uptil now what i have been able to do is i am able to search the xml nodes
based on one particular search string
i.e. in the following way

string matchFrom = "descendant::book[contains(title, '" +searchtitle +
"')]";
XmlNodeList nodelist = doc.SelectNodes(matchFrom);

How can i perform the search based on multiple search criterias and how can i comapre for the date value.

Please help,
Any advice would be helpful,


/*/book[$searchdate > translate(pubdate, '/', '')]
[contains(title, $searchTitle)
or
contains(title, $searchauthor)
]

The xslt-like variable references must be replaced with the specific strings
for the search.
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Nov 12 '05 #2

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

Similar topics

0
by: Harald Weiser | last post by:
Hi Folks, If I try a FulltextSearch with searchStrings that are in different tables I get the Error-Message 16945 SQL ERROR, The cursor was not declared. Why do I need a cursor here because I...
5
by: Alan Mackenzie | last post by:
I've recently moved onto a C++ project with a large number of directories (several hundred) containing an even larger number of C++ source files. There are vastly more ways in C++ to obfuscate a...
3
by: googleboy | last post by:
Hi there. I have defined a class called Item with several (about 30 I think) different attributes (is that the right word in this context?). An abbreviated example of the code for this is: ...
8
by: Gordon Knote | last post by:
Hi can anyone tell me what's the best way to search in binary content? Best if someone could post or link me to some source code (in C/C++). The search should be as fast as possible and it would...
33
by: Geoff Jones | last post by:
Hiya I have a DataTable containing thousands of records. Each record has a primary key field called "ID" and another field called "PRODUCT" I want to retrieve the rows that satisy the following...
4
by: Hunk | last post by:
Hi I have a binary file which contains records sorted by Identifiers which are strings. The Identifiers are stored in ascending order. I would have to write a routine to give the record given...
5
by: peruron | last post by:
Hello again! I've been discussing the advantages of Python over C-Shell. I was asked if I can replace the use of "grep" in searching for a specific string in a multi-file directory - I have to go...
1
by: veer | last post by:
Hi i made program on searching and if a word is present in a file more than one time this program search it one time and exit the file but i want to show all the locations of the searched word in...
2
by: napsters | last post by:
Hello...I want to make something in VB (Version 9) that reads multiple data from specified file (Access 2007) and displays content in list box. If file doesn't exist, alert user. More...
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: 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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.