Home > Back-end >  How to select elements containing special characters in XPath?
How to select elements containing special characters in XPath?

Time:10-11

I am trying to exclude three <td> elements from a result set:

<td>
    &#x1F947;
</td>
<td>
    &#x1F948;
</td>
<td>
    &#x1F949;
</td>

I've tried using:

td[not(contains(., '&#x1F948;'))]

For example, but the element I don't want still comes back...

CodePudding user response:

In the xpath expression, you need to use the escape conventions of the host language. Using &-escaping is fine if the host is XSLT, but if it’s JavaScript, for example, you’ll need to use backslash escaping.

CodePudding user response:

To avoid the labyrinth of escaping conventions, just use literal Unicode characters themselves, which can be searched and then copy-and-pasted from sites such as Compart:

Char Entity Ref Literal Unicode XPath
&#x1F947;
  • Related