I am using third party code for HTML To PDF conversion is working good.But this cannot accept rowspan why?? Here is my code.
require('WriteHTML.php');
$pdf=new PDF_HTML();
$pdf->AliasNbPages();
$pdf->SetAutoPageBreak(true, 15);
$pdf->AddPage();
$pdf->SetFont('Arial','B',14);
$pdf->WriteHTML('<para><h1>Title</h1>');
$pdf->SetFont('Arial','B',7);
$htmlTable="<TABLE border='1'>
<TR height='40'>
<TD>S.NO</TD>
<TD>Type Of Beneficiary</TD>
<TD>Expected</TD>
<TD>No.Of Beneficiary</TD>
<TD>No.Of Packs Issued</TD>
<TD>Ave.monthly Usage</TD>
<TD>Balance Stock Available</TD>
</TR>
<TR>
<TD>1</TD>
<TD>Adolescents Girls</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD ></TD>
</TR>
<TR>
<TD rowspan='4'>2</TD>
<TD>Normal</TD>
<TD>ALLOTMENT NO</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD rowspan='4'></TD>
</TR>
<TR>
<TD>LSCS</TD>
<TD>ALLOTMENT NO</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
</TR>
<TR>
<TD>Puperial Sterilization</TD>
<TD>ALLOTMENT NO</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
</TR>
<TR>
<TD>Total</TD>
<TD>ALLOTMENT NO</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
<TD>QUANTITY</TD>
</TR>
<TR>
<TD>3</TD>
<TD>Women Prison Inmates</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD>4</TD>
<TD>Women IMH Inmates</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD>5</TD>
<TD>Total</TD>
<TD> </TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>";
$pdf->WriteHTML2("$htmlTable");
$pdf->Output();
It seems FPDF doesn't support rowspan:
FPDF does not recognize rowspan or colspan. Here is a workaround that
you can try, using empty cells and the border attribute for Cell.
by Sean (emphasis mine) - here is the full answer
Rowspan and Colspan supporting the TCPDF Library.And also easy configration this one. Library path http://www.tcpdf.org/ and coding path http://www.tcpdf.org/examples/example_048.phps. just change the path only. require_once('tcpdf.php');
Related
Problem: Currently I have problem aligning the PDF that I am creating as it is different with normal CSS that I know.
Problem:
What I need it to be solve:
Make it align, for the image I provided, I wanted "No.SAG" below "Old"
This is the code:
<table class="unstyledTable">
<thead>
<tr>
<th>Name:</th>
<th>Test Data</th>
<th></th>
<th>Number card IC</th>
<th></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<td>Name Agent::</td>
<td>TomHansom </td>
<td></td>
<td>New:</td>
<td>foot5</td>
<td></td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Address:</td>
<td>werwrwrwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwww</td>
<td></td>
<td>Old:</td>
<td>cell5_1</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>No.SAG:</td>
<td>cell5_2</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>Number.Siri:</td>
<td>cell5_3</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
Might be easier to put both in columns as tables in a parent table. Check out my code below to see if this is what you were after.
<table class="unstyledTable">
<tbody>
<tr>
<td valign="top"><table>
<tbody>
<tr class="unstyledTable">
<th>Name:</th>
<th>Test Data</th>
</tr>
<tr class="unstyledTable">
<td>Address:</td>
<td>werwrwrwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwww</td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td>Name Agent::</td>
<td>TomHansom </td>
</tr>
</tbody>
</table></td>
<td valign="top"><table>
<tbody>
<tr class="unstyledTable">
<th>Number card IC</th>
<th></th>
</tr>
<tr class="unstyledTable">
<td>Old:</td>
<td>cell5_1</td>
</tr>
<tr class="unstyledTable">
<td>No.SAG:</td>
<td>cell5_2</td>
</tr>
<tr class="unstyledTable">
<td>Number.Siri:</td>
<td>cell5_3</td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td>New:</td>
<td>foot5</td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
I am using HTml2pdf library to convert HTML to PDF.
Below is the code i am using.
PHP
require __DIR__.'/vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
$html2pdf = new Html2Pdf();
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->setTestTdInOnePage(false);
$html = file_get_contents('index.html');
$html2pdf->writeHTML($html);
$html2pdf->output();
HTML
<div class="bap">
<div class="row">
<div class="par_col">
<div class="column">
<img src="b.jpg" alt="test">
<table style="width:99%" class="feetop">
<tr>
<td class="t_head">Challan No.</td>
<td class="lii undl">18584</td>
<td class="t_heada">Due Date:</td>
<td class="liia undl"></td>
</tr>
<tr>
<td class="t_head_c">Name</td>
<td colspan="3" class="lii undl">Hamza Zafeer</td>
</tr>
<tr>
<td>Program:</td>
<td class="lii undl de">BS Civil Tech </td>
<td >Roll No.</td>
<td class="undl"></td>
</tr>
<tr>
<td>Semester</td>
<td class="undl"></td>
<td>Session</td>
<td class="undl">2018-2021</td>
</tr>
</table>
<table style="width:99%" class="fee">
<tr>
<th >PARTICULARS</th>
<th>Rs.</th>
<th>Ps.</th>
</tr>
<tr>
<td>Registration Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Admission Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tuition Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Laboratory Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Library Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transcript / Degree Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Examination Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Security Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hostel Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transport charges</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Fine</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Misc.</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>Total Payable</td>
<td>1000</td>
<td></td>
</tr>
</table>
<div class="btm">
<div class="fm rss"><strong>Rs. in words :</strong> One thousand only</div>
<div class="fm bt"> Cashier</div>
</div>
</div></div>
<div class="par_col">
<div class="column">
<img src="a.jpg" alt="test">
<table style="width:99%" class="feetop">
<tr>
<td class="t_head">Challan No.</td>
<td class="lii undl">18584</td>
<td class="t_heada">Due Date:</td>
<td class="liia undl"></td>
</tr>
<tr>
<td class="t_head_c">Name</td>
<td colspan="3" class="lii undl">Hamza Zafeer</td>
</tr>
<tr>
<td>Program:</td>
<td class="lii undl de">BS Civil Tech </td>
<td >Roll No.</td>
<td class="undl"></td>
</tr>
<tr>
<td>Semester</td>
<td class="undl"></td>
<td>Session</td>
<td class="undl">2018-2021</td>
</tr>
</table>
<table style="width:99%" class="fee">
<tr>
<th >PARTICULARS</th>
<th>Rs.</th>
<th>Ps.</th>
</tr>
<tr>
<td>Registration Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Admission Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tuition Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Laboratory Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Library Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transcript / Degree Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Examination Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Security Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hostel Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transport charges</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Fine</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Misc.</td>
<td>1000</td>
<td></td>
</tr>
</table>
<div class="btm">
<div class="fm rss"><strong>Rs. in words :</strong> One thousand only</div>
<div class="fm bt"> Cashier</div>
</div>
</div></div>
<div class="par_col">
<div class="column">
<img src="s.jpg" alt="test">
<table style="width:99%" class="feetop">
<tr>
<td class="t_head">Challan No.</td>
<td class="lii undl">18584</td>
<td class="t_heada">Due Date:</td>
<td class="liia undl"></td>
</tr>
<tr>
<td class="t_head_c">Name</td>
<td colspan="3" class="lii undl">Hamza Zafeer</td>
</tr>
<tr>
<td>Program:</td>
<td class="lii undl de">BS Civil Tech </td>
<td >Roll No.</td>
<td class="undl"></td>
</tr>
<tr>
<td>Semester</td>
<td class="undl"></td>
<td>Session</td>
<td class="undl">2018-2021</td>
</tr>
</table>
<table style="width:99%" class="fee">
<tr>
<th >PARTICULARS</th>
<th>Rs.</th>
<th>Ps.</th>
</tr>
<tr>
<td>Registration Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Admission Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tuition Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Laboratory Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Library Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transcript / Degree Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Examination Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Security Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hostel Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transport charges</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Fine</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Misc.</td>
<td>1000</td>
<td></td>
</tr>
</table>
<div class="btm">
<div class="fm rss"><strong>Rs. in words :</strong> One thousand only</div>
<div class="fm bt"> Cashier</div>
</div>
</div></div>
OUTPUT of HTML
But When i generate PDF, each section converted into a single page, and final PDF consisted on 3 pages.
Problem
It should not generate the 3 pages of PDF. Anybody can tell me what i am doing wrong, why it is creates 3 pages instead of 1 page?
I think it lacks the space, try to wrap your tables in one more table, like:
<table>
<tr>
<td>%table1HTML%</td>
</tr>
<tr>
<td>%table2HTML%</td>
</tr>
<tr>
<td>%table3HTML%</td>
</tr>
</table>
I'm trying to create a pdf out of an html table which is created through php.
I use php version 5.4.7 and mdpf version 5.7.3.
This code does not work:
<?php
include('../../mpdf/mpdf.php');
$mpdf=new mPDF('utf-8', 'A4-L');
$test2 = "<table class='timon' border='1'>
<thead>
<tr>
<th></th>
<th>Montag</th>
<th>Dienstag</th>
<th>Mittwoch</th>
<th>Donnerstag</th>
<th>Freitag</th>
<th>Avg. Tag</th>
</tr>
</thead>
<tbody>
<tr>
<td>Morgen (0.3) </td>
<td><s>test user 0.36</s><br /></td>
<td></td>
<td><s>test user 0.26</s><br /></td>
<td></td>
<td></td>
<td> </td>
</tr>
<tr>
<td>Mittag (0.5) </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td> </td>
</tr>
<tr>
<td>Nachmittag (0.5) </td>
<td><s>test user 0.16</s><br /></td>
<td></td>
<td></td>
<td></td>
<td><s>test user 0.46</s><br /></td>
<td> </td>
</tr>
<tr>
<td>Ganzer Tag (1) </td>
<td></td>
<td></td>
<td><s>test user 1.2</s><br /></td>
<td></td>
<td></td>
<td> </td>
</tr>
<tr>
<td>Total Auslastung</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>Total Gruppe</td>
<td>7.5</td>
<td>7.5</td>
<td>7.5</td>
<td>7.5</td>
<td>7.5</td>
<td>7.5</td>
</tr><tr>
<td>Freie Plätze</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
</tr>
</tbody>
</table>";
$mpdf->WriteHTML($test2,2);
$filename = "test.pdf";
$mpdf->Output($filename,'I');
exit;
?>
If I remove just one of the < s> tags, the PDF will be created fine. Eg.:
<td><s>test user 0.36</s><br /></td>
<td>test user 0.36<br /></td>
it also have problems with the < b> and < u> tag.
Any ideas?
You must close the <s> tag. mPDF is very strict with opening and closing tags. And not all of your opening tags are closed.
f.i.
<td><s>test user 0.36<s><br /></td>
Is not closed properly.
I found the mistake. I had an additional php include and this php had an body and html tag in it. I just removed it and now it works fine. BR
I have a report to be exported in xls format. The report was exported successfully in xls format but gridlines never show up even I have adjusted some options in the ms excel by checking the view gridline checkbox but gridlines still show nothing. I have suspected if maybe there is something wrong with my php export code. can you please help me with this? Here is my code.
xls export code
<?php
$file="report.xls";
$export ='<center><h1 class="lead">CITY Chamber</h1><img src= "base_url(images/agri_logo.jpg)" width="130px" height="130px"></center>
<div id="page-wrapper">
<table class="table table-bordered table-hover table-striped tablesorter">
<tr>
<td>First Name: </td>
<td>'.$report_rows[0]->fname.'</td>
</tr>
<tr>
<td>Last Name: </td>
<td>'. $report_rows[0]->lname.'</td>
</tr>
<tr>
<td>Gender: </td>
<td>'.$report_rows[0]->gender.'</td>
</tr>
<tr>
<td>Contact Number: </td>
<td>'.$report_rows[0]->contact.'</td>
</tr>
</table>
<table class="table table-bordered table-hover table-striped tablesorter">
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped tablesorter">
<thead>
<tr>
<td colspan="2"><strong>Key Result Areas (KRA) / Program / Projects / Activities</strong></td>
<td><strong>Target</strong></td>
<td colspan="2" style="text-align:center;"><center> '.$report_rows[0]->prev_month_year.'</center></td>
<td colspan="2" ><center> '.$report_rows[0]->pres_month_year.' </center></td>
<td><strong>Total</strong></td>
</tr>
</thead>
<form id="at_report_form" method="post">
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td> '.$dropdown_brgy1[$data_reports['prev_brgy1']].' </td>
<td> '.$dropdown_brgy1[$data_reports['prev_brgy2']].' </td>
<td> '.$dropdown_brgy1[$data_reports['pres_brgy1']].' </td>
<td> '.$dropdown_brgy1[$data_reports['pres_brgy2']].' </td>
<td></td>
</tr>
<tr>
<td>1. KRA No. 1: Production Enhancement & Environment </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td> Protection Agenda (PEEPA)</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1.1 Support to Crop Production Enhancement </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1.1.1 Rice Production Self Sufficiency Program</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><span style="margin-left:30px;">a. Provision of certified seeds</span></td>
<td>no. of bags</td>
<td>per AT</td>
<td><center> '.$data_reports['a'].'</center></td>
<td> <center>'.$data_reports['b'].'</center></td>
<td><center> '.$data_reports['c'].'</center></td>
<td> <center>'.$data_reports['d'].'</center></td>
<td><center> '.$data_reports['total_1'].'</center></td>
</tr>
<tr>
<td></td>
<td>no. of farmers</td>
<td></td>
<td><center>'.$data_reports['e'].'</center></td>
<td><center>'.$data_reports['f'].'</center></td>
<td><center>'.$data_reports['g'].'</center></td>
<td><center>'.$data_reports['h'].'</center></td>
<td><center>'.$data_reports['total_2'].'</center></td>
</tr>
<tr>
<td style="text-align:center;">Rehab Seeds</td>
<td>no. of bags</td>
<td>per AT</td>
<td><center>'.$data_reports['i'].'</center></td>
<td><center>'.$data_reports['j'].'</center></td>
<td><center>'.$data_reports['k'].'</center></td>
<td><center>'.$data_reports['l'].'</center></td>
<td><center>'.$data_reports['total_3'].'</center></td>
</tr>
<tr>
<td></td>
<td>no. of farmers</td>
<td></td>
<td><center>'.$data_reports['m'].'</center></td>
<td><center>'.$data_reports['n'].'</center></td>
<td><center>'.$data_reports['o'].'</center></td>
<td><center>'.$data_reports['p'].'</center></td>
<td><center>'.$data_reports['total_4'].'</center></td>
</tr>
<tr>
<td><span style="margin-left:30px;">b. Provision of pest control assistance</span></td>
<td>no. of kgs (ratoxin)</td>
<td>per AT</td>
<td><center>'.$data_reports['q'].'</center></td>
<td><center>'.$data_reports['r'].'</center></td>
<td><center>'.$data_reports['s'].'</center></td>
<td><center>'.$data_reports['t'].'</center></td>
<td><center>'.$data_reports['total_5'].'</center></td>
</tr>
</tbody>
</form>
</table></div></div>';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $export; ?>
Output (Gridlines never show up even I have checked the gridlines view checkbox):
optput ur html using table tags
use
<table border=1>
I successfully parsed a dynamic table with the following PHP code:
$docH = new DOMDocument();
$docH->loadHTMLFile($url);
//get everything inside the body element:
$bodyH = $docH->getElementsByTagName('body')->item(0);
foreach ($bodyH->childNodes as $childNode) {
echo $docH->saveHTML($childNode);
}
Parsed HTML Table:
<table>
<tr>
<td>5CG</td>
<td>aass</td>
<td>sxs</td>
<td>sx</td>
<td>EK</td>
<td></td>
<td>72</td>
</tr>
<td></td>
<td>samplxs</td>
<td>xs</td>
<td></td>
<td>xss</td>
<td>fkxsx aus</td>
<td>s</td>
</tr>
<td></td>
<td>5AH.</td>
<td>ds</td>
<td>d</td>
<td>sdf</td>
<td>sdfsdf aus</td>
<td></td>
</tr>
<tr>
<td>6CG</td>
<td>3.</td>
<td>sfd</td>
<td></td>
<td>scs</td>
<td>das aus</td>
<td>a</td>
</tr>
<tr>
<td>7DG</td>
<td>6.</td>
<td>s</td>
<td>s</td>
<td>sD</td>
<td>sdsa.</td>
<td></td>
</tr>
<td></td>
<td>samplxs</td>
<td>xs</td>
<td></td>
<td>xss</td>
<td>fkxsx aus</td>
<td>s</td>
</tr>
<tr>
<td>7DG, 7CG, 7CR</td>
<td>6.</td>
<td>NsdR</td>
<td>s</td>
<td>SP</td>
<td>fasdlt aus</td>
<td>s</td>
</tr>
<td></td>
<td>samplxs</td>
<td>xs</td>
<td></td>
<td>xss</td>
<td>fkxsx aus</td>
<td>s</td>
</tr>
<tr>
<td>9BR</td>
<td>6.</td>
<td>FEI</td>
<td>sa</td>
<td>DE</td>
<td>fasdad aus</td>
<td></td>
</tr>
<tr>
<td>9AR, 9BR, 9CR</td>
<td>62.</td>
<td>BEH</td>
<td></td>
<td>sd</td>
<td>fasda aus</td>
<td></td>
</tr>
<tr>
<td></td>
<td>6.</td>
<td>MLR</td>
<td></td>
<td>FdR</td>
<td>fsdfaus</td>
<td></td>
</tr>
<tr>
<td>E10C</td>
<td>6.</td>
<td>sdf</td>
<td>d</td>
<td>d</td>
<td>fsdfs aus</td>
<td></td>
</tr>
<tr>
</table>
But my goal is to just show the content of the table the user wants by asking for just the <tr> elements in which the first <td> of the first <tr> includes some text until there is another <tr> which first <td> has a different content.
For example: If the user types "9BR" into an input field, I just want him to see:
9BR
6.
FEI
sa
DE
fasdad aus
9AR, 9BR, 9CR
62.
BEH
sd
fasda aus
6.
MLR
FdR
fsdfaus
If he types in 5CG:
<tr>
<td>5CG</td>
<td>aass</td>
<td>sxs</td>
<td>sx</td>
<td>EK</td>
<td></td>
<td>72</td>
</tr>
<td></td>
<td>samplxs</td>
<td>xs</td>
<td></td>
<td>xss</td>
<td>fkxsx aus</td>
<td>s</td>
</tr>
Or if 6CG just:
<tr>
<td>6CG </td>
<td>3. </td>
<td>sfd </td>
<td> </td>
<td>scs </td>
<td>das aus</td>
<td>a </td>
</tr>
Using XPath, something like this should do the trick
http://de3.php.net/manual/en/class.domxpath.php
$xpath = new DomXpath($docH);
$trs = $xpath->query('//tr[td[1][contains(text(), "BR9")]]');
find all tr which first td contains text "anything"
as for the following ´tr´s with empty first td
this might not be the most elegant form to query this, but would work:
$query = '
//tr[td[1][contains(text(), "anything")]]
|
//tr[td[1][contains(text(), "anything")]]
/following-sibling::tr[td[1][not(text())] and preceding-sibling::tr[1][td[1][not(text()) or contains(text(), "anything")]]]
';
find all tr which first td contains text "anything"
also find all tr which first td is empty and whose preceding siblings (trs) first td
is also empty or contains text "anything"
example: http://3v4l.org/q6eDu