473,396 Members | 1,766 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,396 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 9984

"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: 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: 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
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.