473,387 Members | 1,535 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.

text/string finder

Hi,

I'm new to xml and sometimes gives me a hardtime. is there any xpah query
that returns a particular string I'm looking for?

I used: //*contains(text()="foo") the "foo" could be in any part of xml
file. it could be text or attribute or ....
any idea?

thanks in advance
c# newbiew
Nov 12 '05 #1
2 9983

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

I'm new to xml and sometimes gives me a hardtime. is there any xpah query
that returns a particular string I'm looking for?

I used: //*contains(text()="foo") the "foo" could be in any part of xml
file. it could be text or attribute
This is not a syntactically correct XPath expression.

Probably you meant:

//*[contains(text(), 'foo')]
This will select all *element* nodes that have at least one *text node*
child that contains the string 'foo'

No attribute nodes will be selected.

If you need an XPath expression that will also select all attribute nodes
containing the string 'foo', one such XPath expression is:

(//* | //@*)[contains(., 'foo')]

If you want to include other types of nodes in the search, too (e.g.
comments and processing instructions), then one way to select all such
nodes, containing the string 'foo' is to evaluate the following XPath
expression:

(//node() | //@*)[contains(., 'foo')]
If you need to extend your search over namespace nodes, too, use this XPath
expression:

(//node() | //@* | //namespace::*)[contains(., 'foo')]
Hope this helped.
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

or ....
any idea?

thanks in advance
c# newbiew

Nov 12 '05 #2
Yes thanks

"Dimitre Novatchev [MVP XML]" <dn********@yahoo.com> wrote in message
news:c1*************@ID-152440.news.uni-berlin.de...

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

I'm new to xml and sometimes gives me a hardtime. is there any xpah query that returns a particular string I'm looking for?

I used: //*contains(text()="foo") the "foo" could be in any part of xml file. it could be text or attribute
This is not a syntactically correct XPath expression.

Probably you meant:

//*[contains(text(), 'foo')]
This will select all *element* nodes that have at least one *text node*
child that contains the string 'foo'

No attribute nodes will be selected.

If you need an XPath expression that will also select all attribute nodes
containing the string 'foo', one such XPath expression is:

(//* | //@*)[contains(., 'foo')]

If you want to include other types of nodes in the search, too (e.g.
comments and processing instructions), then one way to select all such
nodes, containing the string 'foo' is to evaluate the following XPath
expression:

(//node() | //@*)[contains(., 'foo')]
If you need to extend your search over namespace nodes, too, use this

XPath expression:

(//node() | //@* | //namespace::*)[contains(., 'foo')]
Hope this helped.
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

or ....
any idea?

thanks in advance
c# newbiew


Nov 12 '05 #3

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

Similar topics

5
by: tmb | last post by:
I need to search a folder & sub-folders for key words in ASP files... I can open the files with Notepad and see the text string there... But when I try to navigate to the folder with Windows...
2
by: johkar | last post by:
Would there ever be any problems with the following script depending on what type of characters are in the text string? I am appending the value of hidden form field to the query string. ...
4
by: Nedo | last post by:
hi is there a simple way to convert a html-string to a plain text-string? thanks Nedo
2
by: charlie_M | last post by:
I have the following code: <script type=text/javascript> function hide_tooltip(){ var hp = document.getElementById("tooltipper"); hp.style.left=0; hp.style.top=0; hp.style.width=1;...
2
by: UJ | last post by:
I have need to convert a text string (with formatting) to an image. This is so that I can resize the image to different sizes and the formatting stays exactly the same regardless of the size. I...
6
by: larry mckay | last post by:
Hi, Does anyone have any simple text string encryption routines that are easy to implement? I'm trying to prevent users and system administrators from figuring out how I implement things....
25
by: electrixnow | last post by:
in MS VC++ Express I need to know how to get from one comma delimited text string to many strings. from this: main_string = "onE,Two,Three , fouR,five, six " to these: string1 =...
5
by: geotso | last post by:
Here is the scenario: 1. I have a table (tblCalendar) with the following fields: caldID caldDate caldTitle caldInfo nWinW nWinH
4
by: Ahmed, Shakir | last post by:
I need to remove text string from the list of the numbers mentioned below: 080829-7_A 070529-5_c 080824-7_O 070405_6_p The output will be : 080829-7 070529-5
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.