Hi I'm trying to parse a Wikipedia document in which there is a table called "infobox biota" with this structure. I'm trying to get the following table data and classes of the following characteristics
Kingdom:
Phylum:
Subphylum:
Class:
Order:
Family:
<table class="infobox biota" style="text-align: left; width: 200px; font-size: 100%">
<tbody><tr>
<th colspan="2" style="text-align: center; background-color: rgb(211,211,164)">Rabbit</th>
</tr>
<tr>
<td colspan="2" style="text-align: center"><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Rabbit_in_montana.jpg/250px-Rabbit_in_montana.jpg" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Rabbit_in_montana.jpg/375px-Rabbit_in_montana.jpg 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Rabbit_in_montana.jpg/500px-Rabbit_in_montana.jpg 2x" height="222" width="250"></td>
</tr>
<tr>
<th colspan="2" style="text-align: center; background-color: rgb(211,211,164)">Scientific classification</th>
</tr>
<tr>
<td>Kingdom:</td>
<td><span class="kingdom" style="white-space:nowrap;">Animalia</span></td>
</tr>
<tr>
<td>Phylum:</td>
<td><span class="phylum" style="white-space:nowrap;">Chordata</span></td>
</tr>
<tr>
<td>Subphylum:</td>
<td><span class="subphylum" style="white-space:nowrap;">Vertebrata</span></td>
</tr>
<tr>
<td>Class:</td>
<td><span class="class" style="white-space:nowrap;">Mammalia</span></td>
</tr>
<tr>
<td>Order:</td>
<td><span class="order" style="white-space:nowrap;">Lagomorpha</span></td>
</tr>
<tr>
<td>Family:</td>
<td><span class="family" style="white-space:nowrap;">Leporidae<br>
<small>in part</small></span></td>
</tr>
<tr>
<th colspan="2" style="text-align: center; background-color: rgb(211,211,164)">Genera</th>
</tr>
<tr>
<td colspan="2" style="text-align: left">
<div>
<table style="background-color:transparent;table-layout:fixed;" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr valign="top">
<td>
<div style="margin-right:20px;">
<p><i>Pentalagus</i><br>
<i>Bunolagus</i><br>
<i>Nesolagus</i><br>
<i>Romerolagus</i></p>
</div>
</td>
<td>
<div style="margin-right: 20px;">
<p><i>Brachylagus</i><br>
<i>Sylvilagus</i><br>
<i>Oryctolagus</i><br>
<i>Poelagus</i></p>
</div>
</td>
</tr>
</tbody></table>
</div>
</td>
</tr>
</tbody></table>
Here is my attempt to parse and obtain the kingdom,phylum,subphylum,class,order and family of a rabbit with the table structure. However I get a the following Array ( [Kingdom:] => [Phylum:] => [Subphylum:] => [Class:] => [Order:] => [Family:] => [
Pentalagus
Bunolagus
Nesolagus
Romerolagus
] => )
it doesnt fill in the array with the data for the rabbit. also it give me a parse error in the line shown below, what can be wrong?
<?php
//require"mydb.php";
header('Content-type: text/html; charset=utf-8'); // this just makes sure encoding is right
include('simple_html_dom.php'); // the parser library
$html = file_get_html('http://en.wikipedia.org/wiki/Rabbit');
$table = $html->find('table.infobox');
$data = array();
foreach($table[0]->find('tr') as $row)
{
$td = $row->find('> td');
if (count($td) == 2)
{
$name = $td[0]->innertext;
$text = $td[1]->find('a')[0]->innertext; //PARSE ERROR IS GIVEN HERE, after the find('a')[0], taking off the array takes away the error but just me no results
$data[$name] = $text;
}
}
print_r($data);
?>
$text = $td[1]->find('a')[0]->innertext;
In this line you are dereferencing a function. This is only available in PHP 5.4 or later. Try this instead:
$td = $td[1]->find('a');
$text = $td[0]->innertext;
Related
I want to convert html file into pdf using mpdf class. working well but the count > 30 the page rotating no display ,
<?php
include("connection.php");
$phase=mysql_query("select * from session where status=1");
$phasee = mysql_fetch_array($phase);
$mindate = $phasee['st_date'];
$maxdate = $phasee['end_date'];
$query_omr = mysql_query("SELECT * from sit_details a,staff_details b where b.staff_code=a.staff_code and a.val_center=".$_GET['num']);
$staffrowdet = mysql_fetch_array($query_omr);
$query_exam_session = mysql_query("SELECT * from exam_session");
$row_exam_session = mysql_fetch_array($query_exam_session);
$randm=rand(100001,999999);
$text_page='
<style>
table {
width:1000px;
font-family:Times New Roman, Times;
border-collapse: collapse;
text-align:justify;
padding:2px;
font-size:12px;
text-transform: uppercase;
}
td, th {
height:30px;
text-transform: uppercase;
padding:2px;
}
</style>
<table id="simple-table" >
<tr><td colspan="2">
<table>
<tr>
<td rowspan="3"><img src="assets/images/logo.gif" width="80px" /></td>
<td align="center" style="font-size:20px"><strong>Heading1 </strong></td>
</tr>
<tr>
<td align="center" style="font-size:16px"><strong>Heading2 - '. $row_exam_session['session'].' </strong> </td>
</tr>
<tr>
<td align="center" style="font-size:14px"><strong>DETAIL</strong></td>
</tr>
</table>
</td></tr>
<tr><td colspan="2">
<table id="dynamic-table" class="table table-striped table-bordered table-hover" width="900" align="left">
<tr>
<th colspan="6" style="font-size:14px" align="left">PERIOD : FROM <u>'.$mindate .' </u> TO <u>'.$maxdate.' </u> </th>
</tr>
<div style="width:50px;height:50px;border:1px solid #000;"></div>
</table>
</td></tr>
<tr>
<td>
<strong><caption> Form Details</caption> </strong>
<table id="dynamic-table" class="table table-striped table-bordered table-hover" border="1" style="page-break-inside: avoid"> <tr bgcolor="#CCCCCC" >
<th align="center" width="50px"><label class="control-label bolder blue">Sl.No </label></th>
<th align="center" width="100px"><label class="control-label bolder blue">Staff ID </label></th>
<th align="left" width="100px"><label class="control-label bolder blue"> Staff Name</label></th>
<th align="left" width="100px"><label class="control-label bolder blue"> Designation </label></th>
</tr>';
$c1=0;
while($row_dummy = mysql_fetch_array($query_omr)) {
$text_page=$text_page.'
<tr>
<td align="center"><h3>'. $c1 .'</h3></td>
<td align="center"><h3>'. $row_dummy['staff_code'].'</h3></td>
<td align="left"><h3>'. $row_dummy['staff_name'].'</h3></td>
<td align="left"><h3>'. $row_dummy['staff_designation'].'</h3></td>
</tr>';
$c1++;
}
$text_page=$text_page.'
<tr>
<table >
</tr>
</table>
</table>
</td>
</tr>
<table id="dynamic-table" class="table table-striped table-bordered table-hover" border="1" width="800" >
<tbody>
<tr>
<th align="center" width="300px" ></th> <br/>
<th align="center" width="150px">Post Held</th>
<th align="center" width="250px">Name</th>
<th align="center" width="50px">Signature</th>
</tr>
<tr>
<td> </td>
<td align="center" height="70"><strong> <br/> Officer / <br/> Coordinator </strong> </td>
<td height="70"></td>
</tr>
<tbody>
<td align="right" width="300px" valign="bottom" rowspan="2" > </td>
</table>
</table>
<table>
<tr><td align="left"><h4>'.$randm.'</h4></td><td align="right"><h4>'.date('d-m-Y H:i:s').'</h4></td></tr>
</table>
';
//echo $text_page;
//exit;
ob_end_clean();
ini_set('memory_limit', '500000M');
include("MPDF57/mpdf.php");
//$mpdf = new mPDF('c', 'A4-L','0', '0', '10', '10','10', '10');
$mpdf = new mPDF(
'', // mode - default ''
'A4', // format - A4, for example, default ''
0, // font size - default 0
'', // default font family
10, // margin_left
10, // margin right
5, // margin top
0, // margin bottom
5, // margin header
5, // margin footer
'P' // L - landscape, P - portrait
);
$mpdf->autoPageBreak = true;
$mpdf->AddPage();
$fname=$_GET['num'].".pdf";
$mpdf->SetWatermarkImage('assets/images/logo.jpg');
$mpdf->setFooter('{PAGENO}');
$mpdf->showWatermarkImage = true;
$mpdf->WriteHTML($text_page);
$mpdf->Output($fname, 'D');
exit;
?>
the pdf downloaded, but the count<30 if the rowcount>30 the page not responding. how to solve this error. i cannot find out the solution. kindly suggest any other mpdf sample program which is matching my requirement.
I tried to do it but the big problem is foreach here i have the foto:
Problem
Here is my table picture
Here is the code but still have problem:
<div class="row">
<table class="table table-bordered table-striped table-highlight">
<tbody>
<tr height="100">
<td rowspan="6" height="120" width="3%" style="vertical-align: middle;">
<p style="white-space: nowrap;writing-mode: vertical-lr;transform: rotate(180deg);font-weight: bold;"><font >Here is my title </font></p>
</td>
<td colspan="3">
<font>Name</font>
</td>
<td width="64">
<font>Article</font>
</td>
<td width="64">
<font>Price</font>
</td>
<td width="64">
<font>Date</font>
</td>
</tr>
<tr height="20">
<td colspan="3" rowspan="5" height="120" ></td>
<td rowspan="5" style="vertical-align: top;"></td>
<td rowspan="5" style="vertical-align: top;"></td>
<td rowspan="5" style="vertical-align: top;"></td>
</tr>
<tr height="15">
</tr>
<tr height="15">
</tr>
<tr height="15">
</tr>
<tr height="15">
</tr>
</tbody>
</table>
</div>
How can i do it so that when i use foreach it will insert new td and the vertical Here is my title will be there?
ok, so you're using php here's a very basic example on how you can do that, i'm assuming you already did query and the fetching part, and this is a guess of your data structure, you can adjust it to your liking :
<div class="row">
<table class="table table-bordered table-striped table-highlight">
<tbody>
<tr height="100">
<td rowspan="100%" height="120" width="3%" style="vertical-align: middle;">
<p style="white-space: nowrap;writing-mode: vertical-lr;transform: rotate(180deg);font-weight: bold;"><font >Here is my title </font></p>
</td>
<td colspan="3">
<font>Name</font>
</td>
<td width="64">
<font>Article</font>
</td>
<td width="64">
<font>Price</font>
</td>
<td width="64">
<font>Date</font>
</td>
</tr>
<?php
foreach($data as $key => $value){
echo '<tr height="20">';
echo '<td colspan="3">'.$value['name'].'</td>';
echo '<td width="64" style="vertical-align: top;">'.$value['article'].'</td>';
echo '<td width="64" style="vertical-align: top;">'.$value['price'].'</td>';
echo '<td width="64" style="vertical-align: top;">'.$value['date'].'</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
here's a fiddle : https://jsfiddle.net/kkpjx328/
I hope this helps .
PS : on your next question, please consider adding the data structure and if possible, an example or code sample of what you've tried so far so we can provide more specific answers
I am trying to render an HTML page as PDF in using DOMPDF version 0.8 on CodeIgniter running on Windows 7 64 bit. My development machine runs PHP 7 on XAMPP on a Windows 10 Pro but the production server runs PHP 5.6 on Windows 7 professional 64bit.
I realize that when I run the application on my local machine, everything works well and the PDF is properly generated with the images and styles properly displayed in place. But when I deploy to the production machine, the styles and the images dont render properly again. The images dont display and the styles are not rendered.
Please I will appreciate any suggestions to resolve this issue
Here are some parts of my codes below:
//Application/libraries/pdf.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once("./vendor/dompdf/dompdf/src/autoloader.php");
use Dompdf\Dompdf;
class Pdf
{
public function generate($html, $filename='', $stream=TRUE, $paper = 'A4',
$orientation = "landscape")
{
$dompdf = new DOMPDF();
$dompdf->loadHtml($html);
$dompdf->setPaper($paper, $orientation);
$dompdf->render();
if ($stream)
{
$dompdf->stream($filename.".pdf", array("Attachment" => 1));
}
else
{
return $dompdf->output();
}
}
}
//Application/controllers/report.php
...some code removed for brevity
$this->load->library('pdf');
$html=$this->load->view('parts/pdf-head',NULL,true);
$html.=$this->load->view('admin/reports/periodic/pdf',['results'=>$_SESSION['students_result']],true);
$this->pdf->generate($html,'report');
//Application/views/admin/reports/periodic/pdf.php
<?php
if(empty($results))
{
echo "<div class='alert alert-danger'><span class='fa fa-warning'></span> No result found in record for the selected parameters</div>";
}
else
{
foreach($results['scores'] as $student=>$scores)
{
?>
<table class="table table-bordered" style="padding: 10px">
<tr class="tr-row2">
<td colspan="16" style="text-align: center">
<?php echo img(['src'=>"style-resources/logo2.png", 'width'=>"50px"]);?>
</td>
</tr>
<tr class="tr-row2">
<td colspan="16" style="text-align: center">
<?php echo $results['campus'];?>
</td>
</tr>
<tr class="tr-row2">
<td colspan="16" style="text-align: center">
<?php echo $results['title'];?>
</td>
</tr>
<tr class="tr-row2">
<th colspan="10" style="text-align: left;">
<?php echo strtoupper($scores['student_info']['student_names']);?>
</th>
<td colspan="6">
<?php echo $scores['student_info']['class'].', '.$scores['student_info']['class_arm']; ?>
</td>
</tr>
<tr class="tr-row2">
<td colspan="7" style="text-align: right">Number of class contacts </td><td style="text-align: left"><?php echo $scores['student_info']['attendance'];?></td><td colspan="7" style="text-align: right">Student's Attendance</td><td style="text-align: left"><?php echo $scores['attendance_score'];?></td>
</tr>
<tr class="tr-row2">
<th>C.A.1 (10%)</th><td><?php echo $scores['ca1']; ?></td><th>C.A.2 (10%)</th><td><?php echo $scores['ca2']; ?></td><th>Classwork (15%)</th><td><?php echo $scores['classwork']; ?></td><th> Attendance (5%)</th><td><?php echo $scores['attendance_score'];?></td><th>EXAM (60%)</th><td><?php echo $scores['exam']; ?></td><th>TOTAL (100%)</th><td><?php echo $scores['total'];
?></td><th>Grade</th><td><?php echo $scores['grade']; ?></td><th>POSITION</th><td><?php $this->load->helper('ordinalize'); echo ordinalize(array_search($scores['total'],$_SESSION['result_total'])+1); ?></td>
</tr>
<tr class="tr-row2">
<th colspan="3">Highest Score</th><td><?php echo max($_SESSION['result_total']); ?></td><th>Lowest Score</th><td><?php echo min($_SESSION['result_total']); ?></td><th>Class Average</th><td><?php echo array_sum($_SESSION['result_total'])/count($_SESSION['students_result']['scores']) ?></td><th colspan="3">Effort</th><td colspan="5" style="text-align: left"><?php echo $scores['effort'];?> </td>
</tr>
<tr>
<th colspan="6">
<table class="table table-striped table-bordered">
<tr class="tr-row2">
<td colspan="2" style="text-align: center">
Accomplishments for the Term
</td>
</tr>
<tr class="tr-row2">
<th>Exercise/Activity</th>
<th>Score</th>
</tr>
<?php
if(empty($scores['scores'][1]))
{
echo "<tr class='tr-row2'><td colspan='2'><em> No lesson exercise found for this student</em></td></tr>";
}
else {
foreach ($scores['scores'][1] as $a => $b) {
if ($a != 'total') {
echo "<tr class='tr-row2'><th>" . $a . "</th><td>" . $b . "</td></tr>"; ?>
<?php }
}
}
?>
<tr class="tr-row2"><th colspan="2" style="text-align: center">Summary of report</th></tr>
<tr class="tr-row2">
<td colspan="2"><em><?php echo $scores['comment']; ?></em></td>
</tr>
</table>
</th>
<th colspan="10">
<table class="table table-striped">
<tr class="tr-row2">
<td colspan="2" style="text-align: left">
Skills/Strengths demonstrated
</td>
</tr>
<tr class="tr-row2">
<td colspan="2" style="text-align: left">
<em><?php echo $scores['student_info']['skills'];?></em>
</td>
</tr>
<tr class="tr-row2">
<td colspan="2" style="text-align: left">
Observed Weakness(es)
</td>
</tr>
<tr class="tr-row2">
<td colspan="2" style="text-align: Left">
<em><?php echo $scores['student_info']['weaknesses'];?></em>
</td>
</tr>
<tr class="tr-row2">
<td colspan="2" style="text-align: left">
Remedial steps taken
</td>
</tr>
<tr class="tr-row2">
<td colspan="2" style="text-align: left">
<em><?php echo $scores['student_info']['remedies'];?></em>
</td>
</tr>
<tr class="tr-row2">
<td colspan="2" style="text-align: left">
Further improvement steps to be taken
</td>
</tr>
<tr class="tr-row2">
<td colspan="2" style="text-align: left">
<em><?php echo $scores['student_info']['further_actions'];?></em>
</td>
</tr>
</table>
</th>
</tr>
<tr class="tr-row2">
<th colspan="4" style="text-align: right">Educator's Name</th><td colspan="4" style="text-align: left"><em><?php echo $results['educator']; ?></em></td><th colspan="4" style="text-align: right">Educator's Signature</th><td colspan="4"></td>
</tr>
<tr class="tr-row2">
<th colspan="4" style="text-align: right">Coordinator's Name</th><td colspan="4" style="text-align: left"><em><?php echo $results['coordinator'];?></em></td><th colspan="4" style="text-align: right">Coordinator's Signature</th><td colspan="4"></td>
</tr>
</table>
<?php }
}
.HTACCESS file looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
in this check your RewriteBase.
Then Check your application/config/config.php for $config['base_url'] = 'http://localhost/project_name'; line of code.
i create a report. i try print preview this report.
but i want show 6 data/page page size a4 (landscape).
i already try loop 24 data. and try print preview in google chrome
there 1 data must be down to page 2
see my picture
[![enter image description here][1]][1]
then i check page 2 already same.
this page 2
[![enter image description here][2]][2]
How to fix this, i want report show only 6 data/page
this is my full code, you can try in localhost.
<style>
#caption
{
color:white;
font-weight:bold;
text-align:center;
background-color: #4CAF50;
}
table
{
border-collapse: collapse;
}
th, td
{
padding: 0px;
font-family:arial;
font-size:13px
}
tr:nth-child(even){background-color: #f2f2f2}
th {
background-color: #4CAF50;
color: white;
}
</style>
<table align="center" width="100%" border="1">
<tr>
<td colspan="7" style="vertical-align: top;" id="caption"><font size="3">Data Pendaftar</font></td>
</tr>
<?php
$x = 1;
while($x <= 24)
{
?>
<tr>
<td id="caption">Foto Siswa/i</td>
<td id="caption">Nama Lengkap Siswa/i</td>
<td id="caption">Tempat Lahir</td>
<td id="caption">Tanggal Lahir</td>
<td id="caption">Usia</td>
<td id="caption">L/P</td>
<td id="caption">Agama</td>
</tr>
<tr>
<td align="center" rowspan="3">
<img border="1" src="https://akphoto4.ask.fm/769/854/890/910003014-1s093lj-dc47ceo09kenpt5/original/avatar.jpg"style="width:80px;height:80px;">
</td>
<td align="center">Vasco Da Gama</td>
<td align="center">Spain</td>
<td align="center">01 February 1800</td>
<td align="center">79</td>
<td align="center">L</td>
<td align="center">Kristen</td>
</tr>
<tr>
<td id="caption" colspan="2">Alamat</td>
<td id="caption" colspan="2">No. Telpon | No. Hp </td>
<td id="caption" >Tanggal Daftar</td>
<td id="caption">Status</td>
</tr>
<tr>
<td colspan="2">Spain</td>
<td colspan="2" align="center">0800000000</td>
<td >07 Februari 2000 13:15:33</td>
<td align="center">Pending</td>
</tr>
<?php
$x++;
}
?>
</table>
In this situation, you could create a separate table per page with only 6 rows. Only display the "Data Pendaftar" on the first page, add class="break" to every table except the table on the last page and add a CSS rule table.break{page-break-after:always}. I added a <br /> after each table, so it looks good in the browser before it prints. This will always print 6 rows per page, even when you're accidentally in portrait mode...
<style>
#caption{color:white;font-weight:bold;text-align:center;background-color:#4CAF50}
table{border-collapse:collapse}
th, td{padding: 0px;font-family:arial;font-size:13px}
tr:nth-child(even){background-color:#f2f2f2}
th{background-color:#4CAF50;color:white}
table.break{page-break-after:always}
</style>
<?php $i = 1; while ($i <= 4) { ?>
<table align="center" width="100%" border="1"<?php if ($i < 4) { ?> class="break" <? } ?>>
<?php if ($i == 1) { ?>
<tr>
<td colspan="7" style="vertical-align: top;" id="caption"><font size="3">Data Pendaftar</font></td>
</tr>
<?php } $x = 1; while ($x <= 6) { ?>
<tr>
<td id="caption">Foto Siswa/i</td>
<td id="caption">Nama Lengkap Siswa/i</td>
<td id="caption">Tempat Lahir</td>
<td id="caption">Tanggal Lahir</td>
<td id="caption">Usia</td>
<td id="caption">L/P</td>
<td id="caption">Agama</td>
</tr>
<tr>
<td align="center" rowspan="3">
<img border="1" src="https://akphoto4.ask.fm/769/854/890/910003014-1s093lj-dc47ceo09kenpt5/original/avatar.jpg"style="width:80px;height:80px;">
</td>
<td align="center">Vasco Da Gama</td>
<td align="center">Span</td>
<td align="center">01 Feb 1800</td>
<td align="center">79</td>
<td align="center">L</td>
<td align="center">Kristen</td>
</tr>
<tr>
<td id="caption" colspan="2">Alamat</td>
<td id="caption" colspan="2">No. Telpon | No. Hp </td>
<td id="caption" >Tanggal Daftar</td>
<td id="caption">Status</td>
</tr>
<tr>
<td colspan="2">Spain</td>
<td colspan="2" align="center">021000000 | 0800000000</td>
<td >07 Februari 2000 13:15:33</td>
<td align="center">Pending</td>
</tr>
<?php $x++; } ?>
</table>
<br />
<?php $i++; } ?>
I just started to use PHP Simple HTML DOM Parser.
Now I'm trying to extract all elements surrounded with a <b>-tag inclduing </b> from an exsiting HTML document. This works fine with
foreach($html->find('b') as $q)
echo $q;
How can I achieve to show up only elements surrounded with the <b>,</b>-tags followed by a <span class="marked">?
Update:
I've used firebug to get the css path for the elements. Now it looks like this:
foreach ($html->find('html body div#wrapper table.desc tbody tr td div span.marked') as $x)
foreach ($x->find('html body div#wrapper table.desc tbody tr td table.split tbody tr td b') as $d)
echo $d;
But it won't work... Any Ideas?
Update:
To clarify my question here a sample tr of the document with starting table and ending table tags.
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="desc">
<tr>
<th width="25%" scope="col"><div align="center">1</div></th>
<th width="50" scope="col"><div align="center">2</div></th>
<th width="10%" scope="col"><div align="center">3</div></th>
<th width="15%" scope="col"><div align="center">4</div></th>
</tr>
<tr>
<td valign="top" bgcolor="#E9E9E9"><div style="text-align: center; font-weight: bold; margin-top: 2px"> 1 </div></td>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="split"> <tr>
<td>
<b> element to extract</b></td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="split"> <tr>
<td width="15px" valign="top"> </td>
<td width="15px" valign="top">
<div style="background-color:green ;color:#FFFFFF; text-align:center;padding-bottom: 1px">
1
</div>
</td>
<td>
abed
</td>
</tr>
<tr>
<td width="15px" valign="top"> </td>
<td width="15px" valign="top">
<div style="background-color:green ;color:#FFFFFF; text-align:center;padding-bottom: 1px">
2
</div>
</td>
<td>
ddee
</td>
</tr>
<tr>
<td width="15px" valign="top"> </td>
<td width="15px" valign="top">
<div style="background-color:green ;color:#FFFFFF; text-align:center;padding-bottom: 1px">
3
</div>
</td>
<td>
xdef
</td>
</tr>
<tr>
<td width="15px" valign="top"> </td>
<td width="15px" valign="top">
<div style="background-color:green ;color:#FFFFFF; text-align:center;padding-bottom: 1px">
4
</div>
</td>
<td>
abbcc
</td>
</tr>
<tr>
<td width="15px" valign="top"> </td>
<td width="15px" valign="top">
<div style="background-color:green ;color:#FFFFFF; text-align:center;padding-bottom: 1px">
5
</div>
</td>
<td>
ab
</td>
</tr>
<tr>
<td width="15px" valign="top"> </td>
<td width="15px" valign="top">
<div style="background-color:green ;color:#FFFFFF; text-align:center;padding-bottom: 1px">
6
</div>
</td>
<td>
e1
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top"><div style="text-align: center"> <span class="marked">marked</span> </div></td>
<td valign="top"><div style="text-align: center"> </div></td>
</tr>
</table>
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.
More simple is from manual:
foreach($html->find('b') as $q)
echo $q->plaintext;