Q:

XPATH Matching Sale Price or Regular Price

I need to match either the sale price (if on sale) or the regular price using one expression(hope that's the right term). Here's the two example HTML structures:
On Sale
<span class="price">
<del>
    <span class="woocommerce-Price-amount amount">
        <span class="woocommerce-Price-currencySymbol">&#36;</span>
        14.99
    </span>
</del> 
<ins>
    <span class="woocommerce-Price-amount amount">
        <span class="woocommerce-Price-currencySymbol">&#36;</span>
        12.99
    </span>
</ins>

Regular Price
<p class="price">
<span class="woocommerce-Price-amount amount">
    <span class="woocommerce-Price-currencySymbol">&#36;</span>
    25.00
</span>
</p>

The expression I have so far is:
//*[@class="woocommerce-Price-amount amount"][last()]

It matches on both scenarios but returns both regular and sale prices for the "On Sale" scenario. Do I need some conditional to only return the sale price?
I thought I could possibly only return the last [@class="woocommerce-Price-amount amount"]. I tried last-child but wasn't fully comprehending.

A:

First, note that in your "on sale" snippet, you are missing a closing <span>, but if we fix it, this convoluted expression should do the trick. 
It's formatted for easier reading:
//span[@class="woocommerce-Price-amount amount"]

[parent::p

or

parent::ins

]

Try it on your actual code and see if it works.

