I am using simple_html_dom.php
How to get following data
<td class="t-loss">% Change<strong>-10.75</strong></td>
I want to get -10.75 t-loss occurs only once in html code
<p class="data" id="bseVolume">22,621</p>
I want to get 22,621 bsevolume occurs only once in html code
please let me know what code should I use.
edit more info:
$bseVolume = $content->find("//p[contains(@class, 'data')]");
class : data
appears multiple times in html but id="bseVolume"
appears only once.
I tried
$vaue1 = $html->find("//p[contains(@id, 'bseVolume')]");
$volume1 = $bseVolume1[0]->innertext; echo $volume1 ;
The result is blank. Can you comment?
You can use Simple HTML DOM find to find the <td>
or <p>
elements.
From the docs:
Find (N)th anchor, returns element object or null if not found (zero based)
$ret = $html->find('a', 0);
You could find the <p>
you are looking for like this:
$bseVolume = $html->find("p[id=bseVolume]", 0);
echo $bseVolume->innertext();
You could find the <td>
you are looking for like this:
$tLoss = $html->find("td[class=t-loss] strong", 0);
echo $tLoss->innertext();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.