<label for="options_958_1" class="custom-option-label multi options_958_1_label height-cell- 27" data-column="column-height" data- column-parent="column-parent-height"><span class="default- title">6200°</span>:<span data-option-id="958" class="custom-option- sku">27</span></label>`
I am trying to access the value of 6200° from the dom and then replace it with new text.
For example I would want to replace 6200 with 8500.
This is what the code I have been using after doing some searching but still very new to php and cant get the value.
$kelvin2700 = find(‘span[class=”.options_958_1_label”]’);
Advertisement
Answer
If I understand your correctly, something like this should get you in the right direction:
$doc = new DOMDocument(); $doc->loadHTML('<?xml version="1.0" encoding="UTF-8"?><label for="options_958_1" class="custom-option-label multi options_958_1_label height-cell- 27" data-column="column-height" data-column-parent="column-parent-height"> <span class="default-title">6200°</span> <span data-option-id="958" class="custom-option- sku">27</span></label>'); $xpath = new DOMXpath($doc); $temp = $xpath->query('//label/span[@class="default-title"]'); echo $temp[0]->textContent;
Output:
6200°