473,385 Members | 1,673 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,385 software developers and data experts.

XML Search

Hi Guys,

I know XPath is a good method to search into an xml file but what if
you're looking for a specifc data which could be any where within the xml
file ? Should I consider all possibilities and paths in the xml file ?!!!
Isn't better to have a recurrsive method to traverse the whole tree instead
of passing patterns to "SelectNode" method ?

Let me know if you have experience on this.

Thanks in advace
Newbie
Nov 15 '05 #1
7 3054
XPath is pretty versatile. Any recurrsive method you might write should be
able to be implemented as an XPath expression, but run faster through XPath.
Can you give us an example, maybe someone could give you a snip to try out.

"C# newbie" <rs****@otxresearch.com> wrote in message
news:#$**************@TK2MSFTNGP09.phx.gbl...
Hi Guys,

I know XPath is a good method to search into an xml file but what if
you're looking for a specifc data which could be any where within the xml
file ? Should I consider all possibilities and paths in the xml file ?!!!
Isn't better to have a recurrsive method to traverse the whole tree instead of passing patterns to "SelectNode" method ?

Let me know if you have experience on this.

Thanks in advace
Newbie

Nov 15 '05 #2
GetElementsByTagName is one way to do it.
"C# newbie" <rs****@otxresearch.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi Guys,

I know XPath is a good method to search into an xml file but what if
you're looking for a specifc data which could be any where within the xml
file ? Should I consider all possibilities and paths in the xml file ?!!!
Isn't better to have a recurrsive method to traverse the whole tree instead of passing patterns to "SelectNode" method ?

Let me know if you have experience on this.

Thanks in advace
Newbie

Nov 15 '05 #3

Hi Richard,

Thanks for your response but it was kind of general. As far as, I know
it works for XML TagNames but I'm looking for data which are in any place of
an xml file not any tag name. Let's say I have an xml file as below and my
program should find any thing like "#19384A" or "center" in below code. Does
the "GetElementsByTagName" works for this too ?

<?xml version="1.0"?>
<Form SurveyName="empty" SurveyID="1" StyleUsage="URL"
xmlns=http://www.yahoo.com SurveyProgrammer="ramsin" DateTime="2/12/2004
5:00:54 PM">
<Params>
<BackgroundColor>#19384A</BackgroundColor>
<LinkColor>#ffffff</LinkColor>
<VisitedLinkColor>#ffffff</VisitedLinkColor>
<TextColor>#ffffff</TextColor>
<Direction>ltr</Direction>
<BackgroundImage>
</BackgroundImage>
<Header>&lt;table width='600' cellspacing='0' callpadding='0' border='0'
align='center'&gt;
</Params>
....
.....
......
......
......
</Form>

Thanks

"Richard T. Ed*****@pwpsquared.net" <re****@pwpsquared.net> wrote in message
news:%2********************@TK2MSFTNGP12.phx.gbl.. .
GetElementsByTagName is one way to do it.
"C# newbie" <rs****@otxresearch.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi Guys,

I know XPath is a good method to search into an xml file but what if you're looking for a specifc data which could be any where within the xml file ? Should I consider all possibilities and paths in the xml file ?!!! Isn't better to have a recurrsive method to traverse the whole tree

instead
of passing patterns to "SelectNode" method ?

Let me know if you have experience on this.

Thanks in advace
Newbie


Nov 15 '05 #4
On Tue, 24 Feb 2004 18:35:58 -0800, C# newbie wrote:

Let's say I have an xml file as below and my program should find any
thing like "#19384A" or "center" in below code. Does the
"GetElementsByTagName" works for this too ?


You could use an XPath expression like the following to achieve this:

//*[contains(text(), '#19384A') or contains(text(), 'center')]

Just pass that to SelectNodes and you should be set.

Good luck,

-Derek

Nov 15 '05 #5
Hi Derek,

Thanks for your response but what you said it's imposibile since
SelectNode() works for nodes not data or string embedded among nodes.

"Derek Slager" <de***@activate.net> wrote in message
news:pa****************************@activate.net.. .
On Tue, 24 Feb 2004 18:35:58 -0800, C# newbie wrote:

Let's say I have an xml file as below and my program should find any
thing like "#19384A" or "center" in below code. Does the
"GetElementsByTagName" works for this too ?


You could use an XPath expression like the following to achieve this:

//*[contains(text(), '#19384A') or contains(text(), 'center')]

Just pass that to SelectNodes and you should be set.

Good luck,

-Derek

Nov 15 '05 #6
Hi again Derek,

I liked your idea but I tried it on below xml code. Please if you get a
chance try it maybe there is something that I'm doing wrong! When I ran

//*[contains(text(), 'b1') or bbb the an excpetion error coems up and
compalins about DataSet!

Any idea ?

- <AAA>

<BBB id="b1" />

<BBB id="b2" />

<BBB name="bbb" />

<BBB />

</AAA>

"Derek Slager" <de***@activate.net> wrote in message
news:pa****************************@activate.net.. .
On Tue, 24 Feb 2004 18:35:58 -0800, C# newbie wrote:

Let's say I have an xml file as below and my program should find any
thing like "#19384A" or "center" in below code. Does the
"GetElementsByTagName" works for this too ?


You could use an XPath expression like the following to achieve this:

//*[contains(text(), '#19384A') or contains(text(), 'center')]

Just pass that to SelectNodes and you should be set.

Good luck,

-Derek

Nov 15 '05 #7
Derek,
I have to appreciate you what you said led me to a good solution. Only some
changes to your query
thanks I appreciate it really.


"Derek Slager" <de***@activate.net> wrote in message
news:pa****************************@activate.net.. .
On Tue, 24 Feb 2004 18:35:58 -0800, C# newbie wrote:

Let's say I have an xml file as below and my program should find any
thing like "#19384A" or "center" in below code. Does the
"GetElementsByTagName" works for this too ?


You could use an XPath expression like the following to achieve this:

//*[contains(text(), '#19384A') or contains(text(), 'center')]

Just pass that to SelectNodes and you should be set.

Good luck,

-Derek

Nov 15 '05 #8

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

Similar topics

0
by: R. Rajesh Jeba Anbiah | last post by:
Q: Is PHP search engine friendly? Q: Will search engine spiders crawl my PHP pages? A: Spiders should crawl anything provided they're accessible. Since, nowadays most of the websites are been...
1
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast,...
5
by: George | last post by:
Hi, Anyone has the background for explaining? I have made a search on my name and I have got a link to another search engine. The link's title was the search phrase for the other search engine...
3
by: Alastair | last post by:
Hello guys, I've been building a search facility for an intranet site I'm part of developing and we've been building a search engine using Index Server. It mostly works, however there have been...
39
by: Noticedtrends | last post by:
Can inference search-engines narrow-down the number of often irrelevant results, by using specific keywords; for the purpose of discerning emerging social & business trends? For example, if...
22
by: Phlip | last post by:
C++ers: Here's an open ended STL question. What's the smarmiest most templated way to use <string>, <algorithms> etc. to turn this: " able search baker search charlie " into this: " able...
28
by: joshc | last post by:
If I have an array of data that I know to be sorted in increasing order, and the array is less than 50 elements, and I want to find the first element greater than a certain value, is a simple...
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...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
0
by: passion | last post by:
"Specialized Search Engines" along with Google Search Capability (2 in 1): http://specialized-search-engines.blogspot.com/ Billions of websites are available on the web and plenty of extremely...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.