Search for element value in an XML file

后端 未结 2 501
迷失自我
迷失自我 2021-01-20 14:29

In a given XML file, I\'m trying to search for the presence of a string using XPath in Java. However, even though the string is there, my output is always comi

2条回答
  •  梦毁少年i
    2021-01-20 14:59

    XML/XPath are case-sensitive, your XPath should be

    //article//body//section//region[contains(., 'Perfect')]
    

    To make case-insensitive, use this

    //article//body//section//region[
        contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),
        'perfect')
    ]
    

提交回复
热议问题