xpath substring with case insensitivity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rhitam30111985
    New Member
    • Aug 2007
    • 112

    xpath substring with case insensitivity

    Hi all , i need some validation

    I have an xml like this :

    Code:
    <root>
        <url newurl="aTom Bomb" />
        <url newurl ="tOm and Jerry" />
        <url newurl ="TomBoy" />
        <url newurl ="Random string" />
    </root>
    Now , my aim is to select all the url elements where the newurl attribute contains the word "tom" despite the case. I am using the xpath like this :


    Code:
    var String ="TOM";
    var  xpath = "//url[contains(translate(@newurl, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),'" +  String.toLowerCase()+"')]";
    I am not sure since sometimes it returns correct result and sometime it doesnt ...

    Would appreciate any help.
    Last edited by Dormilich; Mar 5 '09, 09:39 AM. Reason: added more code tags
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Could you post examples of when it returns the correct result and when it doesn't? Can't see anything immediately wrong with what you've provided.

    Comment

    Working...