PDA

View Full Version : C++Qt Getting data from HTML table



danalex07
28th November 2015, 02:44
i'm trying to get data from some table written in HTML, im using QWebFrame and QWebElement i have this table..


<table cellspacing="0" cellpadding="4" id="GridView1" style="color:#333333;border-collapse:collapse;">
<tr style="color:White;background-color:#5D7B9D;font-weight:bold;">
<th scope="col">Factura</th><th scope="col">Fecha de entrega</th><th scope="col">Codigo</th><th scope="col">Serial</th><th scope="col">Cliente</th><th scope="col">Fecha de facturacion</th>
</tr><tr style="color:#333333;background-color:#F7F6F3;">
<td>information 1</td>
<td>information 2</td>
<td>information 3</td>
<td>information 4</td>
<td>information 5</td>
<td>information 6</td>
</tr>
</table>

i'm trying to store in variables each "information" between the <td>..</td> tags for that i'm using


QWebElement information1= frame->findFirstElement("#GridView1 td:nth-child(1)");
QWebElement information2 = frame->findFirstElement("#GridView1 td:nth-child(2)");
QWebElement infomation3 = frame->findFirstElement("#GridView1 td:nth-child(3)");

don't know if its correct to search #GridView1 as the table id and add td:nth-child(n) to find its n child type td......or if there is another way to extract data from the table

ChrisW67
28th November 2015, 20:30
Correct... Does it work?

You use findAll() to get a list of td elements in one query.

danalex07
29th November 2015, 15:54
i was using the formExtractor example to guide myself but i get blank values cuz it uses javascript, i just remove it and convert the qwebelemts to plaintext and worked like a charm..thanx