Results 1 to 3 of 3

Thread: C++Qt Getting data from HTML table

  1. #1
    Join Date
    Sep 2015
    Posts
    22
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Post C++Qt Getting data from HTML table

    i'm trying to get data from some table written in HTML, im using QWebFrameand QWebElementi have this table..

    Qt Code:
    1. <table cellspacing="0" cellpadding="4" id="GridView1" style="color:#333333;border-collapse:collapse;">
    2. <tr style="color:White;background-color:#5D7B9D;font-weight:bold;">
    3. <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>
    4. </tr><tr style="color:#333333;background-color:#F7F6F3;">
    5. <td>information 1</td>
    6. <td>information 2</td>
    7. <td>information 3</td>
    8. <td>information 4</td>
    9. <td>information 5</td>
    10. <td>information 6</td>
    11. </tr>
    12. </table>
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. QWebElement information1= frame->findFirstElement("#GridView1 td:nth-child(1)");
    2. QWebElement information2 = frame->findFirstElement("#GridView1 td:nth-child(2)");
    3. QWebElement infomation3 = frame->findFirstElement("#GridView1 td:nth-child(3)");
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: C++Qt Getting data from HTML table

    Correct... Does it work?

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

  3. #3
    Join Date
    Sep 2015
    Posts
    22
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: C++Qt Getting data from HTML table

    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

Similar Threads

  1. Replies: 1
    Last Post: 8th October 2015, 11:11
  2. Replies: 1
    Last Post: 7th April 2015, 23:28
  3. Getting HTML table cell width
    By sipahi in forum Newbie
    Replies: 12
    Last Post: 2nd February 2013, 12:28
  4. Replies: 1
    Last Post: 8th June 2011, 14:13
  5. Reading table from html code
    By abghosh in forum Qt Programming
    Replies: 4
    Last Post: 23rd February 2010, 18:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.