XQuery looking for text with 'single' quote

后端 未结 6 574
轻奢々
轻奢々 2020-12-03 18:33

I can\'t figure out how to search for text containing single quotes using XPATHs.

For example, I\'ve added a quote to the title of this question. The following line<

6条回答
  •  孤街浪徒
    2020-12-03 19:18

    This is an example:

    /*/*[contains(., "'") and contains(., '"') ]/text()
    

    When this XPath expression is applied on the following XML document:

    
        I'm reading "Harry Potter"
        I am reading "Harry Potter"
        I am reading 'Harry Potter'
    
    

    the wanted, correct result (a single text node) is selected:

    I'm reading "Harry Potter"
    

    Here is verification using the XPath Visualizer (A free and open source tool I created 12 years ago, that has taught XPath the fun way to thousands of people):

    enter image description here

    Your problem may be that you are not able to specify this XPath expression as string in the programming language that you are using -- this isn't an XPath problem but a problem in your knowledge of your programming language.

提交回复
热议问题