How to get only text from ul li?
This is my first time on this forum soo hello;)
I am developing my first professional web page and I need to get the text from the 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 to get only "foo bar" without text in the strong attribute. My code:
$date = $page->find("div[id=siWrapper] ul.siTimeToEnd li.timeInfo");
As a result, this:
dot (u know dot ;)) <strong>sth</strong> foo bar<br/>
I would just:
foo bar
Sorry for my english.
source to share
The easiest way to deal with this is if the page is well-formed with xhtml, you can process it with xpath.
For example,
foreach ($page->xpath("//li") as $date) {
echo $date;
};
must contain all elements <li>
.
If you want a good link to search using xpath expressions, this is pretty good: https://developer.mozilla.org/en-US/docs/Web/XPath
source to share