Html 4.0 in XPATH requests

I do not know exactly why the xpath expression is:

//h3[text()='Foo › Bar']

does not match:

<h3>Foo &rsaquo; Bar</h3>

Is it correct? How to request this markup?

+3
source share
2 answers

XPath does not define any special escape sequences. When XPath is used in XSLT (for example, in the attributes of elements in an XSLT document), escape sequences are processed by an XML processor that reads the stylesheet. If you use XPath in a non-XML context (for example, with Java or C # or another language) through the library, and your XPath query is a string literal in that language, you will not receive any exception handling, except that the language itself usually does.

If it's C # or Java, this should work:

String xpath = "//h3[text()='Foo \u8250 Bar']";
...

XSLT, XSLT XML, &rsaquo; - &lt;, &gt;, &quot;, &apos; &amp;. &#x8250;, DOCTYPE XSLT.

+4

XPath:

XPath XML-,

... , ( "" ) , (, XSLT DTD, ( , XSLT )), , .

escape-, , XPath.

+1

Source: https://habr.com/ru/post/1728677/


All Articles