如何使Xpath Contains()在解析xml时搜索精确匹配?
我的示例xml:如何使Xpath Contains()在解析xml时搜索精确匹配?,xml,xslt,xpath,Xml,Xslt,Xpath,我的示例xml: <root> <test> <para>This is a <comment>new</comment> para</para> </test> </root> 它可以正常工作,因为它包含相同的文本值 如果xml中的文本内容在最后更改 <root> <test> <para>This is a
<root>
<test>
<para>This is a <comment>new</comment> para</para>
</test>
</root>
它可以正常工作,因为它包含相同的文本值
如果xml中的文本内容在最后更改
<root>
<test>
<para>This is a <comment>new</comment> para hightlighted</para>
</test>
</root>
这是一个新的para-hightlighted
它应该返回false。相反,我正在变为现实。
请帮忙。提前感谢。给出:
<root>
<test>
<para id="1">This is a <comment>new</comment> para</para>
<para id="2">This is a <comment>new</comment> para hightlighted</para>
</test>
</root>
匹配para id=“1”
但不匹配para id=“2”
XPath contains()函数按照规范所述执行。你不能改变它的功能。您需要“=”运算符。顺便说一下,XPath计算是在解析XML之后进行的,而不是在解析XML时进行的。
<root>
<test>
<para id="1">This is a <comment>new</comment> para</para>
<para id="2">This is a <comment>new</comment> para hightlighted</para>
</test>
</root>
root/test/para[. = 'This is a new para']