XPath is case-sensitive.
None of the provided XPath expressions selects any node, because in the provided XML document there is no font
element with an attribute named class
(the element font
has a CLASS
attribute and this is different from having a class
attribute due to the different capitalization).
Due to the same reason, font
and FONT
are elements with different names.
These two XPath expressions, when evaluated against the provided XML document, produce the same wanted result:
//div[@class="allpricing"]
/p[@class="priceadorn"]
[last()]
/font[@CLASS="adornmentsText"]
[last()]
and
//p/div[@class="allpricing"]
/p[@class="priceadorn"]
[last()]
/font[@CLASS="adornmentsText"]
[last()]
XSLT - based verification:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select=
'//div[@class="allpricing"]
/p[@class="priceadorn"]
[last()]
/font[@CLASS="adornmentsText"]
[last()]'/>
=============
<xsl:copy-of select=
'//p/div[@class="allpricing"]
/p[@class="priceadorn"]
[last()]
/font[@CLASS="adornmentsText"]
[last()]
'/>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the provided XML document:
<p>
<div class="allpricing">
<p class="priceadorn">
<FONT CLASS="adornmentsText">NOW: </FONT>
<font CLASS="adornmentsText">$1.00</font>
</p>
</div>
</p>
the two expressions are evaluated and the results of this evaluation are copied to the output:
<font CLASS="adornmentsText">$1.00</font>
=============
<font CLASS="adornmentsText">$1.00</font>
as long as its in a valid XML structure and tags are ended properly. Correct me if I'm wrong.