I am in the process of trying to parse HTML with simple_html_dom.php. The HTML I am trying to parse is shown below. I can successfully grab each product name: Product 1, Product 2, Product 3, etc.
I would also like to grab the itemprice_0 from each product. This is where I am running into issues. Here is my code:
<?php
require_once 'simple_html_dom.php';
$html = file_get_html('https://www.webaddress.com');
foreach($html->find('span.productName') as $e)
echo $e.'<br />'; //successfully displays all product names
foreach($html->find('#itemprice_0') as $e)
echo $e; //doesn't display the item prices
foreach($html->find('.dollar') as $e)
echo $e; //doesn't display the dollar amounts
?>
Here is the HTML:
<span class="productName">Product 1</span>
<p class="price">
<strike>
<span class="dollar-symbol">$</span>
<span class="dollar">15</span><span class="dot">.</span>
<span class="cents">99</span></strike>
</p>
<p class="salePrice" id='itemprice_0'>
<span class="dollar-symbol">$</span>
<span class="dollar">13</span><span class="dot">.</span>
<span class="cents">99</span>
</p>
innertext. Tryecho $e->innertext;