Results 1 to 7 of 7

Thread: [RESOLVED] HtmlElement InnerText is incomplete

  1. #1

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Resolved [RESOLVED] HtmlElement InnerText is incomplete

    I am trying to collect information from the table below (which may change in size) that I have loaded in a WebBrowser control.



    I have tried the following code:
    Code:
    Dim table As HtmlElement = webBrowser1.Document.GetElementById("tblMain")
    rtbHazTrax.Text = table.InnerText
    For the above table I get the following output:
    Code:
    Safety Issues and Hazards for 
    Mill Mobile 
    HazardIDDateStatusCapital Investment RequiredAssigned ToLoggerDepartmentWorkAreaHazardClassNote #HazCAPS IDShortDescription
      147306 6/25/2014 12:11:39 PM New No SUSAN HEPSTALL LDC Converting PCMC5 C HAVING TO HAVE SAFETY LOCK CUT OFF 
      147288 6/25/2014 12:36:59 AM Completed No CHARLES RICKETT III CHARLES RICKETT III LDC Converting PCMC9 C pick up broken pallet pieces 
      147276 6/24/2014 2:07:39 PM Completed No WILLIE PARDEN WILLIE PARDEN LDC Converting JRT 1 C weekly ssc checks 
      147243 6/24/2014 2:41:12 AM Completed No MICHAEL BODIFORD CLEVELAND AUSTIN LDC Converti
    I can't explain why the data cuts off at the end, it is very close to being complete. What is even stranger is that every now and then it will be complete. Does anyone know what may be going on here or if not does anyone have a better way of extracting the data from the table? Thank you!
    Last edited by Philly0494; Jun 25th, 2014 at 02:25 PM. Reason: Resolved

  2. #2
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: HtmlElement InnerText is incomplete

    I would ask to see the html if you can post it. Also, you are not pulling the data before the page has completely loaded right? By loaded I dont mean by checking "ReadyState" either, rather, you can see the contents fully-loaded, then you click a button to pull the table innertext, for example.

  3. #3

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: HtmlElement InnerText is incomplete

    Thank you for replying. I think I resolved that issue by executing the code well after the page loads (which is fine for what I am doing) but I overlooked another problem with my method. I am left with a string such as "147276 6/24/2014 2:07:39 PM Completed No WILLIE PARDEN WILLIE PARDEN LDC Converting JRT 1 C weekly ssc checks" which is just the table values separated by spaces but the values themselves contain multiple spaces in them sometimes. Do you have a better way of pulling the data in?

    Here is the InnerHtml for the table:
    Code:
    <TBODY>
    <TR>
    <TD colSpan=100 align=center><FONT size=+1 face=arial>Safety Issues and Hazards for <BR></FONT><FONT size=+3 face=arial>Mill Mobile </FONT></TD></TR>
    <TR class=tableheader>
    <TD align=center><FONT size=1 face=Arial><INPUT id=chkAll onclick=checkAll(); type=checkbox></FONT></TD>
    <TD align=left><FONT size=1 face=Arial>HazardID</FONT></TD>
    <TD align=center><FONT size=1 face=Arial>Date</FONT></TD>
    <TD align=left><FONT size=1 face=Arial>Status</FONT></TD>
    <TD align=left><FONT size=1 face=Arial>Capital Investment Required</FONT></TD>
    <TD align=center><FONT size=1 face=Arial>Assigned To</FONT></TD>
    <TD align=center><FONT size=1 face=Arial>Logger</FONT></TD>
    <TD align=center><FONT size=1 face=Arial>Department</FONT></TD>
    <TD align=center><FONT size=1 face=Arial>WorkArea</FONT></TD>
    <TD align=center><FONT size=1 face=Arial>HazardClass</FONT></TD>
    <TD align=center><FONT size=1 face=Arial>Note #</FONT></TD>
    <TD align=center><FONT size=1 face=Arial>HazCAPS ID</FONT></TD>
    <TD align=center><FONT size=1 face=Arial>ShortDescription</FONT></TD></TR>
    <TR class=tablecolor1>
    <TD align=center><INPUT id=rptTable_ctl01_chkHazard onclick=ResetcheckAll(); name=rptTable$ctl01$chkHazard type=checkbox> <INPUT id=rptTable_ctl01_hdnHazard name=rptTable$ctl01$hdnHazard value=147306 type=hidden> </TD>
    <TD align=center><SPAN id=rptTable_ctl01_lblTitle><A style="COLOR: saddlebrown" href="http://www.app.kcc.com/KCPTrax/EditHazardV2.aspx?SafetyLogID=147306&amp;SID=7"></SPAN><FONT class=tablecolor1 face=Arial>147306 </FONT></A></TD>
    <TD align=center><FONT face=arial>6/25/2014 12:11:39 PM </FONT></TD>
    <TD align=center><FONT face=arial>New </FONT></TD>
    <TD align=center><FONT face=arial>No </FONT></TD>
    <TD align=center><FONT face=arial></FONT></TD>
    <TD align=center><FONT face=arial>SUSAN HEPSTALL </FONT></TD>
    <TD align=center><FONT face=arial>LDC Converting </FONT></TD>
    <TD align=center><FONT face=arial>PCMC5 </FONT></TD>
    <TD align=center><FONT face=arial>C </FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl01_lblWorkOrderWritten></SPAN></FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl01_lblEcapsID></SPAN></FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl01_lblFollowUpEcapsID></SPAN>HAVING TO HAVE SAFETY LOCK CUT OFF </FONT></TD></TR>
    <TR class=tablecolor2>
    <TD align=center><INPUT id=rptTable_ctl02_chkHazard onclick=ResetcheckAll(); name=rptTable$ctl02$chkHazard type=checkbox> <INPUT id=rptTable_ctl02_hdnHazard name=rptTable$ctl02$hdnHazard value=147288 type=hidden> </TD>
    <TD align=center><SPAN id=rptTable_ctl02_lblTitle><A style="COLOR: saddlebrown" href="http://www.app.kcc.com/KCPTrax/EditHazardV2.aspx?SafetyLogID=147288&amp;SID=7"></SPAN><FONT class=tablecolor1 face=Arial>147288 </FONT></A></TD>
    <TD align=center><FONT face=arial>6/25/2014 12:36:59 AM </FONT></TD>
    <TD align=center><FONT face=arial>Completed </FONT></TD>
    <TD align=center><FONT face=arial>No </FONT></TD>
    <TD align=center><FONT face=arial>CHARLES RICKETT III </FONT></TD>
    <TD align=center><FONT face=arial>CHARLES RICKETT III </FONT></TD>
    <TD align=center><FONT face=arial>LDC Converting </FONT></TD>
    <TD align=center><FONT face=arial>PCMC9 </FONT></TD>
    <TD align=center><FONT face=arial>C </FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl02_lblWorkOrderWritten></SPAN></FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl02_lblEcapsID></SPAN></FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl02_lblFollowUpEcapsID></SPAN>pick up broken pallet pieces </FONT></TD></TR>
    <TR class=tablecolor1>
    <TD align=center><INPUT id=rptTable_ctl03_chkHazard onclick=ResetcheckAll(); name=rptTable$ctl03$chkHazard type=checkbox> <INPUT id=rptTable_ctl03_hdnHazard name=rptTable$ctl03$hdnHazard value=147276 type=hidden> </TD>
    <TD align=center><SPAN id=rptTable_ctl03_lblTitle><A style="COLOR: saddlebrown" href="http://www.app.kcc.com/KCPTrax/EditHazardV2.aspx?SafetyLogID=147276&amp;SID=7"></SPAN><FONT class=tablecolor1 face=Arial>147276 </FONT></A></TD>
    <TD align=center><FONT face=arial>6/24/2014 2:07:39 PM </FONT></TD>
    <TD align=center><FONT face=arial>Completed </FONT></TD>
    <TD align=center><FONT face=arial>No </FONT></TD>
    <TD align=center><FONT face=arial>WILLIE PARDEN </FONT></TD>
    <TD align=center><FONT face=arial>WILLIE PARDEN </FONT></TD>
    <TD align=center><FONT face=arial>LDC Converting </FONT></TD>
    <TD align=center><FONT face=arial>JRT 1 </FONT></TD>
    <TD align=center><FONT face=arial>C </FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl03_lblWorkOrderWritten></SPAN></FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl03_lblEcapsID></SPAN></FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl03_lblFollowUpEcapsID></SPAN>weekly ssc checks </FONT></TD></TR>
    <TR class=tablecolor2>
    <TD align=center><INPUT id=rptTable_ctl04_chkHazard onclick=ResetcheckAll(); name=rptTable$ctl04$chkHazard type=checkbox> <INPUT id=rptTable_ctl04_hdnHazard name=rptTable$ctl04$hdnHazard value=147243 type=hidden> </TD>
    <TD align=center><SPAN id=rptTable_ctl04_lblTitle><A style="COLOR: saddlebrown" href="http://www.app.kcc.com/KCPTrax/EditHazardV2.aspx?SafetyLogID=147243&amp;SID=7"></SPAN><FONT class=tablecolor1 face=Arial>147243 </FONT></A></TD>
    <TD align=center><FONT face=arial>6/24/2014 2:41:12 AM </FONT></TD>
    <TD align=center><FONT face=arial>Completed </FONT></TD>
    <TD align=center><FONT face=arial>No </FONT></TD>
    <TD align=center><FONT face=arial>MICHAEL BODIFORD </FONT></TD>
    <TD align=center><FONT face=arial>CLEVELAND AUSTIN </FONT></TD>
    <TD align=center><FONT face=arial>LDC Converting </FONT></TD>
    <TD align=center><FONT face=arial>PCMC9 </FONT></TD>
    <TD align=center><FONT face=arial>C </FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl04_lblWorkOrderWritten></SPAN></FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl04_lblEcapsID></SPAN></FONT></TD>
    <TD align=center><FONT face=arial><SPAN id=rptTable_ctl04_lblFollowUpEcapsID></SPAN>Improper placement </FONT></TD></TR>
    <TR></TR></TBODY>

  4. #4
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: HtmlElement InnerText is incomplete

    Ok so looking at it, I would use .getElementsByTagName ("TR") method to get a collection of TR tags that you can then loop and pull the "TD" child elements. There are a set number of children elements in each TR tag. Check that the count of children elements matches what you expect, and if it matches pull the innertext of each child. How are you expecting to dump the data on screen? Into a text file or what?

  5. #5

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: HtmlElement InnerText is incomplete

    I am going to plop it into an Excel file using Gembox along with some other information. I will not be reading the data as text at any point in the future so if there is a way to save a picture of the table that would work equally well and probably even look nicer. I am trying your method now but another way I was thinking was to set the webbrowser to just the table with this code:
    Code:
    File.WriteAllText(Application.StartupPath + "\\test.html", table.OuterHtml)
                webBrowser1.Navigate(Application.StartupPath + "\\test.html")
    And then I would save the image of the control somehow - which I do not know how to do. I'm trying the tag method now though.
    Last edited by Philly0494; Jun 25th, 2014 at 02:19 PM.

  6. #6

    Thread Starter
    Hyperactive Member Philly0494's Avatar
    Join Date
    Apr 2008
    Posts
    485

    Re: [RESOLVED] HtmlElement InnerText is incomplete

    Thanks your method works great and it is really easy.

  7. #7
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: [RESOLVED] HtmlElement InnerText is incomplete

    you could take a screen capture and save the image if you do not need to read the text.

    Code:
            Dim b As New Bitmap(WebBrowser1.ClientSize.Width, WebBrowser1.ClientSize.Height)
            Dim g As Graphics = Graphics.FromImage(b)
            g.CopyFromScreen(Me.PointToScreen(WebBrowser1.Location), New Point(0, 0), WebBrowser1.ClientSize)
            b.Save(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\test.jpg", ImageFormat.Jpeg)
            Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\test.jpg")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width