<div id="productDetails" class="tabContent active details">
<span>
<b>Case Size:</b>
</span>
44mm
<br>
<span>
<b>Case Thickness:</b>
</span>
13mm
<br>
<span>
<b>Water Resistant:</b>
</span>
5 ATM
<br>
<span>
<b>Brand:</b>
</span>
Fossil
<br>
<span>
<b>Warranty:</b>
</span>
11-year limited
<br>
<span>
<b>Origin:</b>
</span>
Imported
<br>
</div>
How can I get data like 44mm, fossil, etc. by DOM parser in PHP?
the data i can get easily by
$data=$html->find('div#productDetails',0)->innertext;
var_dump($data);
but i want to break it in meta_key and meta_value for my sql table…
i can get the meta_key by
$meta_key=$html->find('div#productDetails span',0)->innertext;
but the meta value related to it????
It’s not that hard, really… just google, and click this link, you now know how to parse a DOM, here you can see what methods you can use to select all elements of interest, iterate the DOM, get its contents and what have you…
That seems to be what you’re after, if I’m not mistaken. This is just off the top of my head, but I think this should output something like:
UPDATE:
Here’s a tested solution, that returns the desired result, if I’m not mistaken:
To insert this in your DB:
Edit
To capture the
11-year limitsubstring entirely, you’ll need to edit the code above like so:The output is: