How do i make Xpath 1.0 query case insensitive

后端 未结 1 1790
自闭症患者
自闭症患者 2021-01-28 22:30

In PHP, I\'m currently making a xpath query but I need to make it case insensitive. I\'m using is XPath 1.0 which from my query means I\'ve got to use some thing called a transl

相关标签:
1条回答
  • 2021-01-28 23:08

    Basically, translate is used to convert dynamic value that you need to compare to be all lower-case (or all upper-case). In this case, you want to apply translate() to rel attribute value, and compare the result to lower-case literal "canonical" (formatted for readability) :

    //link[
        translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'canonical'
    ]
    
    0 讨论(0)
提交回复
热议问题