Parse table in HTML Agility Pack for WP7 - windows-phone-7

I have following HTML:
<table cellspacing="8" cellpadding="6" border="1" style="color: Black; background-color: LightGoldenrodYellow;
width: 60%;" id="GridView2" rules="all">
<tbody>
<tr style="color: White; background-color: #CF4B0A; font-weight: bold;">
<th align="center" scope="col">
Booked At
</th>
<th align="center" scope="col">
Booked On
</th>
<th align="center" scope="col">
Delivered At
</th>
<th align="center" scope="col">
Delivered On
</th>
<th scope="col">
Details
</th>
</tr>
<tr align="left" style="color: #333333; background-color: #FFFBA1; font-family: Arial;
font-size: Small;">
<td align="center">
Not Available
</td>
<td align="center">
Not Available
</td>
<td align="center">
DATA
</td>
<td align="center">
12/01/2012
</td>
<td>
<a href="javascript:__doPostBack('GridView2$ctl02$LinkButton1','')" id="GridView2_ctl02_LinkButton1">
Details</a>
</td>
</tr>
</tbody>
</table>
I would like to parse the above table using HTML Agility pack. I'm using the HAP solution for WP7, downloaded from Codeplex.
Any quick help will be appreciated.

To parse the HTML, use HAP's HtmlDocument.LoadHtml() function and pass it the actual string. That will give you a DOM with all the HTML objects in it.

Related

barryvdh/dompdf not completely showing data in Laravel

i'm working with DomPdf in Laravel. But it not showing all the data.
here's the image (I can't embeded the image because don't have enough reputation) :
IMG1
and this my pdf blade :
body{
background-color: white;
}
.h2pdf{
text-align: center;
}
.h5pdf{
margin-top: -15px;
text-align: center;
}
.devider{
width:100%;
height:10px;
background-color:yellow;
margin-bottom:20px;
margin-top:-10px;
}
.tr-head{
text-align: left;
text-decoration: underline;
text: bold;
font-size: 10px;
height: 1px;
}
.title{
background: #dddddd;
}
.tblpdf{
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
border: 1px solid black;
}
td{
border-left: 1px solid black;
}
.row-fill{
border-bottom: 1px solid black;
}
.page-break {
page-break-after: auto;
}
<body>
<h2 class="h2pdf">Technical Service Report</h2>
<h5 class="h5pdf">Address</h5>
<div class="devider"></div>
<h5 class="h5pdf">TSR No. : {{$head->no_tsr}}</h5>
<table class="tblpdf">
<tr class="title">
<td colspan="3">Customer & Mechanic Detail</td>
</tr>
<tr class="tr-head">
<td>Report By</td>
<td>Mechanic Arrival Date & Time</td>
<td>Technician</td>
</tr>
<tr class="row-fill">
<td>{{$head->report_creator}}</td>
<td>{{date('d-M-Y H:i',strtotime($head->mechanic_arrival_date))}}</td>
<td>{{$head->mechanic_name}}</td>
</tr>
<tr class="tr-head">
<td>Customer</td>
<td>PIC</td>
<td>Site/Province</td>
</tr>
<tr class="row-fill">
<td>{{$head->customer_name}}</td>
<td>{{$head->customer_pic}}</td>
<td>{{$head->customer_site}}</td>
</tr>
<tr class="title">
<td colspan="3">Unit & Failure Detail</td>
</tr>
<tr class="tr-head">
<td>Brand</td>
<td>Model</td>
<td>Category</td>
</tr>
<tr class="row-fill">
<td>{{$head->unit_brand}}</td>
<td>{{$head->unit_model}}</td>
<td>{{$head->unit_category}}</td>
</tr>
<tr class="tr-head">
<td>Serial Number</td>
<td>Hourmeter</td>
<td>Kilometer</td>
</tr>
<tr class="row-fill">
<td>{{$head->unit_sn}}</td>
<td>{{$head->unit_hm}}</td>
<td>{{$head->unit_km}}</td>
</tr>
<tr class="tr-head">
<td>Chasis SN</td>
<td>Engine SN</td>
<td>Machine Application</td>
</tr>
<tr class="row-fill">
<td>{{$head->unit_chasis_sn}}</td>
<td>{{$head->unit_engine_sn}}</td>
<td>{{$head->unit_application}}</td>
</tr>
<tr class="tr-head">
<td>Commisioning Date</td>
<td></td>
<td></td>
</tr>
<tr class="row-fill">
<td>
#if($head->unit_commissioning_date!=NULL)
{{date('d-m-Y',strtotime($head->unit_commissioning_date))}}
#elseif($head->unit_commissioning_date == NULL)
UNKNOWN
#endif
</td>
<td></td>
<td></td>
</tr>
<tr class="tr-head">
<td>Faulty Type</td>
<td>Date & Time of Servicing</td>
<td>Date & Time Completion</td>
</tr>
<tr class="row-fill">
<td>{{$head->faulty_type}}</td>
<td>{{date('d-M-Y H:i',strtotime($head->job_beginning_date))}}</td>
<td>
#if(date('Y-m-d',strtotime($head->job_complete_date))!= '1970-01-01')
{{date('d-m-Y H:i',strtotime($head->job_complete_date))}}
#elseif(date('Y-m-d',strtotime($head->job_complete_date)) == '1970-01-01')
UNFINISHED JOB
#endif
</td>
</tr>
<tr class="tr-head">
<td>Faulty Group</td>
<td>Job Type</td>
<td>Job Status</td>
</tr>
<tr class="row-fill">
<td>{{$head->faulty_group}}</td>
<td>{{$head->job_type}}</td>
<td>{{$head->job_status}}</td>
</tr>
<tr class="tr-head">
<td colspan="3" style="border-top:1px solid black;">Condition</td>
</tr>
<tr class="row-fill">
<td colspan="3">{{$head->unit_condition}}</td>
</tr>
<tr class="title" style="margin-top:5px;">
<td colspan="3">Failure (Complaints)</td>
</tr>
<tr>
<td colspan="3">{!!$head->job_complaint!!}</td>
</tr>
<tr class="title">
<td colspan="3">Failure (Analysis)</td>
</tr>
<tr>
<td colspan="3">{!!$head->job_analysis!!}</td>
</tr>
<tr class="title">
<td colspan="3">Failure (Correction)</td>
</tr>
<tr>
<td colspan="3">{!!$head->job_correction!!}</td>
</tr>
<tr class="title">
<td colspan="3">Failure (Parts)</td>
</tr>
<tr>
<td colspan="3">{!!$head->job_failure_parts!!}</td>
</tr>
</table>
<div class="page-break"></div>
<a>Photo(s)</a>
<table style="text-align:center;border: solid 1px;border-collapse: collapse;">
<tr class="row-fill">
<td colspan="2">
<img src="{{public_path().'/images/TSR/'.$head->url_photo_unit}}" width="350px" height="300px" alt="Unit"><br>Unit
</td>
</tr>
<tr>
<td>
<img src="{{public_path().'/images/TSR/'.$head->url_photo_sn}}" width="350px" height="300px" alt="SN"><br>Serial Number
</td>
<td>
<img src="{{public_path().'/images/TSR/'.$head->url_photo_hm}}" width="350px" height="300px" alt="Hm"><br>Hourmeter
</td>
</tr>
</table>
<div class="page-break"></div>
<table style="border: solid 0.5px;width:100%;text-align: center" >
<tr><td></td></tr>
<?php
$rcount = 0;
foreach($detail as $record){
if ($rcount % 2 == 0){
echo '<tr>';
}
?>
<td>
<img src="{{public_path().'/images/TSR/'.$record->url_photo}}" width="350px" height="300px" alt="image">
<label for="description">{{$record->description}}</label>
</td>
<?php if ($rcount % 2 == 2){
echo '</tr>';
}
$rcount++;
}
//here is a check condition in case you don't have more times multiple of 3 rows
if ($rcount % 2 != 0){
echo '</tr>';
}
?>
</table>
</body>
I already tried the page-break css with :
page-break-before : always
page-break-before : auto
page-break-after : always
page-break-after : auto
But nothing changed. I don't know what the problem is. Please help me, thanks in advance.
I found a way to solve this issue. The data shown completely when we use div instead of table. We just need to add some css on the div so the data will show like we're using table.
Hopefully other people can solve the problem with this method.

Change font weight also change font-family Laravel--dompdf

If I change font weight it also change the font-family of it. How can I stop it
body{
font-family: 'sans-serif';
}
<body>
<table style="width: 100%">
<tr style="font-weight: 500">
<td style="font-size: 11px;">Shipper Account #</td>
<td style="font-size: 12px;">9585558</td>
</tr>
<tr style="font-weight: 500">
<td style="font-size: 11px;">Shipper Account #</td>
<td style="font-size: 12px;">9585558</td>
</tr>
</table>
</body>

Laravel Blade view not showing passed data from controller

I have a button that will show data based on specific ID:
<td style="text-align: center; vertical-align:middle;">
Stripe Payment
</td>
The route is:
Route::get('payment/{id}', 'BookingController#payment')->middleware('verified');
The BookingController#payment is:
public function payment($id)
{
$bookings= \App\Booking::find($id);
return view('parking.payment')->with('bookings',$bookings);
}
and the blade view is:
<table class="table">
<thead>
<tr>
<th style="text-align: center; vertical-align:middle;">Booking ID</th>
<th style="text-align: center; vertical-align:middle;">Application Status</th>
<th style="text-align: center; vertical-align:middle;">Semester</th>
<th style="text-align: center; vertical-align:middle;">Parking Area</th>
<th style="text-align: center; vertical-align:middle;">Parking Lot No.</th>
<th style="text-align: center; vertical-align:middle;">Payment</th>
</tr>
</thead>
#foreach($bookings as $book)
<tr>
<td style="text-align: center; vertical-align:middle; color:red;">{{$book['booking_id']}}</td>
<td style="text-align: center; vertical-align:middle;">{{$book['apply_status']}}</td>
<td style="text-align: center; vertical-align:middle;">{{$book['semester']}}</td>
<td style="text-align: center; vertical-align:middle;">{{$book['park_area']}}</td>
<td style="text-align: center; vertical-align:middle;">{{$book['park_no']}}</td>
<td style="text-align: center; vertical-align:middle;">{{$book['price']}}</td>
</tr>
</table>
#endforeach
But, the blade view only shows blank table. Is it because the data conflicts with the Stripe payment form that i make in the same page?
$bookings = \App\Booking::find($id); will return a single Booking, but based on your naming and the loop in the blade view it seems that you were expecting a collection. Perhaps you wanted \App\Booking::where('booking_id', $id)->get()? (I'm not totally clear on your database structure)

Css border lines not showing when assigned to td tags in PDF file generated by DOMPDF

I'm rendering a table using DomPDF 0.6, now I need to have borders throughout each cell. If I use then the cellpadding and cellspacing affects the width of the border so I can't use it.
Now I have my table
$html = '<table border="0" cellspacing="0" cellpadding="4" width="100%" style="border:1px solid #000;">
<tr>
<td class="borderOk"> </td>
<td class="borderOk" align="center" colspan="2" style="font-size:18px;font-weight:normal;"><i>'.$pName1.'</i></td>
<td class="borderOk" align="center" colspan="2" style="font-size:18px;font-weight:normal;"><i>'.$pName2.'</i></td>
</tr>
<tr>
<td class="borderOk"><strong><i>Price</i></strong></td>
<td class="borderOk" colspan="2" > </td>
<td class="borderOk" colspan="2" > </td>
</tr>
<tr>
<td class="borderOk"><strong><i>Options</i></strong></td>
<td class="borderOk" colspan="2" > </td>
<td class="borderOk" colspan="2" > </td>
</tr>
<tr>
<td class="borderOk" > </td>
<td class="borderOk" colspan="2" > </td>
<td class="borderOk" colspan="2" > </td>
</tr>
</table>';
With my styles that look like this "Also is within the $html variable at the top"
<style type="text/css">
td .borderOk{
border-style: solid;
border-width: 1px;
border-color: #A5C3E0;
}
</style>
The borders show perfectly in my Browser but when rendering it using domPDF the pdf file shows without the inner td borders, only the outline border is shown.
My DomPDF code looks like this
$dompdf = new DOMPDF();
$dompdf->load_html($_SESSION['html'],'UTF-8');
$dompdf->set_paper('a4', 'portrait');
$dompdf->render();
$dompdf->stream(date("YmdHis").".pdf");
Your CSS selector should be
td.borderOk
(without the space)
Or better : add the borderOK class to the table and leave your CSS as it is.
I had the same issue. Remove the border="0" then do as Fabien noted: td.borderOk or just .borderOk
Try to use dompdf version 0.6.0 beta3. It will work for sure. I had tried your code.
http://code.google.com/p/dompdf/downloads/detail?name=dompdf_0-6-0_beta3.tar.gz

Finding table values in watij using xpath

I am using watij to automate my UI testing. I have many tables in a webpage. I need to find a table which has a width 95%. It contains many rows. I have to find each row with different text say "running first UI test on local" as below adn need to get the td value "Complete". I am not ble to get the value but I get the watij address. Let me know how I can find this.
<table width=95%>
<tr>
<th align="left">
<span id="lblHeaderComponent" style="font-size:10pt;font-weight:bold;">Component</span>
</th>
<th align="left">
<span id="lblHeaderServer" style="font-size:10pt;font-weight:bold;">Server</span>
</th>
<th align="left">
<span id="lblHeaderStatus" style="font-size:10pt;font-weight:bold;">
</span>
</th>
</tr>
<tr>
<td align="left"
nowrap="nowrap" style="font-size:12px;">running first UI test on local</td>
<td align="left" style="font-size:12px;">Google</td>
<td align="left" style="font-size:12px;">
<a style='color:#336600;'>Complete</a>
</td>
</tr>
<tr>
<td align="left"
style="border-top:1px solid #cfcfcf;border-bottom:1px solid #cfcfcf;"
colspan="3"
style="font-size:12px; color:#ff3300;">
</td>
</tr>
<tr>
<td align="left" nowrap="nowrap" style="font-size:12px;">running second UI test on local</td>
<td align="left" style="font-size:12px;">Google</td>
<td align="left" style="font-size:12px;">
<a style='color:#336600;'>Complete</a>
</td>
</tr>
</table>
You can try an xpath visualizer like this one to assist you in getting the right expression. It lets you see the results visually.
Using XPath on HTML assumes the HTML is XHTML - in other words it must be well-formed XML.

Resources