Unanswered selectSingleNode Case sensitive ..

  • Wednesday, August 01, 2012 10:07 PM
     
     

    Hi 

    My XML-file is as below 
    <Server> 
    +<Name>myServer</Name>
    ++<Instances>
    +++<Instance>
    ++++<Name>ABC_Instance</Name>
    +++++<Databases>
    ++++++<Database>
    +++++++<Name>testdb</Name>
    +++++++++<Tables>
    ++++++++++<Table>
    +++++++++++<owner>
    .
    .
    . .

    +++++++++</Table>++++++++</Database>
    ++++++</Databases>
    ++++</Instance>
    ++</Instances>
    +</Server>

    Now i need to find specific database node. I need to do a case insensitive comparision 
    i.e If I pass the below string as argument to searchString() it returns NULL 
    '//SQLServerRepository/Server[Name="MyServer"]/Instances/Instance[Name="ABC_Instance"]/Databases/Database[Name="[translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')= 'TestDB']"]'
    '//SQLServerRepository/Server[Name="MyServer"]/Instances/Instance[Name="ABC_Instance"]/Databases/Database[Name="[translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')= 'testDB']"]'
    '//SQLServerRepository/Server[Name="MyServer"]/Instances/Instance[Name="ABC_Instance"]/Databases/Database[Name="[translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')= 'TESTDB']"]'
    '//SQLServerRepository/Server[Name="MyServer"]/Instances/Instance[Name="ABC_Instance"]/Databases/Database[Name="[translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')= 'testdb']"]'

    Only the last search string where the db matches with that in XML returns properly all others returns NULL. Can I know where i am going wrong with this. 

    Thanks 
    Santosh.B.B.

    • Edited by santoshbb Wednesday, August 01, 2012 10:10 PM
    •  

All Replies

  • Thursday, August 02, 2012 3:49 AM
     
     

    HI,

    Any help on this.

    santosh

  • Monday, August 06, 2012 3:21 PM
     
      Has Code

    The problem is in here: Server[Name='MyServer']

    Try Server[Name='myServer']

    Your translate function lowercases a string so you should use the following XPATH:

    //SQLServerRepository/Server[Name="myServer"]/Instances/Instance[Name="ABC_Instance"]/Databases/Database[Name="[translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')= 'testdb']"]


    My blog

    Whether you’re a construction worker, a forum moderator, or just someone that likes helping people. I think these guidelines can be helpful in keeping you helpful when being helpful.