1

I want to print all lines starting with a "+" and which have a keyword such as "hasRole".

String search="//td[contains(@class,'blob-code blob-code-addition') and contains(text(),'hasRole')]";

I know a simple and condition will not be enough. How do I formulate the XPATH search for this?

Here's a screenshot. enter image description here

Also,how do I make this search case insensitive?

Zack
  • 2,078
  • 10
  • 33
  • 58

2 Answers2

0

I tried the below and it worked.

String search="//td[(contains(@class,'blob-code blob-code-addition') and contains(.,'HasRole')) or (contains(@class,'blob-code blob-code-deletion') and contains(.,'HasRole'))]";
Zack
  • 2,078
  • 10
  • 33
  • 58
0

You can use something like this:

//td[(contains(lower-case(@class), 'blob-code blob-code-addition') ... 

OR

//td[(contains(translate(@class, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), 'blob-code blob-code-addition') ... 
Jon...
  • 309
  • 2
  • 3
  • 11
  • I want to match "hasRole" with ignore case. I am not concerned about the class – Zack Feb 18 '15 at 04:28
  • It's the same. ... contains(lower-case(.),'hasrole') ... OR ... contains(translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), 'hasrole') ... – Jon... Feb 18 '15 at 04:38