This is the code i use so far:
$urlIn1 = "http://www.sportsdirect.com/slazenger-mens-canvas-shoes-246033?colcode=24603325";
libxml_use_internal_errors(true);
$docIn1 = new DOMDocument();
$docIn1->loadHTMLFile($urlIn1);
$docIn1->preserveWhiteSpace = false;
$docIn1->formatOutput = true;
$xpathIn1 = new DOMXpath($docIn1);
$Price = $xpathIn1->query('//span[@id="dnn_ctr103511_ViewTemplate_ctl00_ctl07_ctl01_lblSellingPrice"]')->item(0)->nodeValue;
echo $Price;
With this code i echo
the price.
My question is:
How can i get all the values from the options from the select menu with id dnn_ctr103511_ViewTemplate_ctl00_ctl09_sizeDdl
which do NOT have class='greyOut'
.
After i get all the values from the options from the select menu i have to format them in one line looking like this.
Expected final result:
7 (41), 7.5 (41.5), 8 (42), 8.5 (42.5), 9 (43), 9.5 (43.5), 10 (44), 11 (45), 12 (46)
I think you can use this xpath expression to get the wanted options from the select menu with id dnn_ctr103511_ViewTemplate_ctl00_ctl09_sizeDdl
:
//select[@id="dnn_ctr103511_ViewTemplate_ctl00_ctl09_sizeDdl"]/option[not(contains(@class, "greyOut")) and not(contains(@selected, "selected"))]
Then you can loop the result from the DOMXPath::query and create an array with all the prices and use implode to create your one line presentation.
For example:
$urlIn1 = "http://www.sportsdirect.com/slazenger-mens-canvas-shoes-246033?colcode=24603325";
libxml_use_internal_errors(true);
$docIn1 = new DOMDocument();
$docIn1->loadHTMLFile($urlIn1);
$docIn1->preserveWhiteSpace = false;
$docIn1->formatOutput = true;
$xpathIn1 = new DOMXpath($docIn1);
$domNodeList = $xpathIn1->query('//select[@id="dnn_ctr103511_ViewTemplate_ctl00_ctl09_sizeDdl"]/option[not(contains(@class, "greyOut")) and not(contains(@selected, "selected"))]');
$prices = array();
foreach ($domNodeList as $domElement) {
$prices[] = $domElement->nodeValue;
}
echo implode(', ', $prices);