I am first time on this forum soo hello ;)
I am developing my first professional web page and I have to get text from li element. I am using PHP Simple HTML DOM Parser Manual.
<ul class="siTimeToEnd">
<li class="left smaller timeInfo">
<strong>sth</strong>
foo bar
</li>
</ul>
I would like get only 'foo bar' without text in strong attribute.
My code:
$date = $page->find("div[id=siWrapper] ul.siTimeToEnd li.timeInfo");
The result it's:
dot (u know dot ;)) <strong>sth</strong> foo bar<br/>
I would get just:
foo bar
I am sorry for my English.
The easiest way of handling this is, if the page is well-formed xhtml, you can handle it by using xpath.
For example,
foreach ($page->xpath("//li") as $date) {
echo $date;
};
should get you all <li> elements.
If you need a good reference for how to search using xpath expressions, this is a pretty good one: https://developer.mozilla.org/en-US/docs/Web/XPath
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With