I just started to use PHP Simple HTML DOM Parser.
Now I\'m trying to extract all elements surrounded with a -tag inclduing
More simple is from manual:
foreach($html->find('b') as $q)
echo $q->plaintext;
Try the following CSS selector
b > span.marked
That would return the span though, so you probably have to do $e->parent()
to get to the b element.
Also see Best Methods to parse HTML for alternatives to SimpleHtmlDom
Edit after update:
Your browser will modify the DOM. If you look at your markup, you will see that there is no tbody elements. Yet Firebug gives you
html body div#wrapper table.desc tbody tr td div span.marked'
html body div#wrapper table.desc tbody tr td table.split tbody tr td b'
Also, your question does not match the queries. You asked how to find
elements surrounded with the
<b>,</b>
-tags followed by a<span class="marked">
That can be read to either mean
<b><span class="marked">foo</span></b>
or
<b><element>foo</element></b><span class="marked">foo</span>
For that first use the child combinator I have shown earlier. For the second, use the adjacent sibling combinator
b + span.marked
to get the span and then use $e->prev_sibling()
to return the previous sibling of element (or null if not found).
However, in your shown markup, there is neither nor. There is only a DIV with a SPAN child having the marked class
<div style="text-align: center"> <span class="marked">marked</span>
If that is what you want to match, it's the child combinator again. Of course, you have to change the b then to a div.