i need to grab the text inside a label with a specific class that has a checked radio input inside it.
This is the HTML:
<div id="ships-from2">
<label for="ship_hk_intl">
<input type="radio" name="ship_mode_name" id="ship_hk_intl" data-action="http://www.example.com/" value="hk_intl">
Hong Kong Warehouse - USD44.31
</label>
<label for="ship_us_intl">
<input type="radio" name="ship_mode_name" id="ship_us_intl" data-action="http://www.example.com/" checked value="us_intl">
United States Warehouse - USD45.10
</label>
</div>
.
I need:
the string inside the label that has a checked radio button.
The actuall radio button might change so i need to check which one is checked
I am scraping the dom and using xpath but have no idea how to write the query Ideas anyone?
EDIT 1 - CODE THUS FAR (response to @TimDev):
$div = $dom->getElementById('ships-from2');
$query = '//input[@checked]/../text()';
$e = $xpath->query($query, $div);
echo 'TEST:'.trim($e->item(1)->nodeValue);