Re: thead not at the top of a table goes missing

View: New views
1 Messages — Rating Filter:   Alert me  

Re: thead not at the top of a table goes missing

by Ahmed Ashour :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi,
 
* You must subscribe to the list before posting.
 
----
Blog: http://asashour.blogspot.com


----- Forwarded Message ----

Note: Forwarded message is attached.



The attached code will produce the following output on the following two
simple html tables. Note in the second table, the "6|Banana" row is
missing. Any ideas?


---------------------------

6|Banana|
5|Bicycle|
3|John|

5|Bicycle|
3|John|



----------

<html><head><body>
<table id="table1">

<thead>
<tr>
<td>6</td>
<td>Banana</td>
</tr>
</thead>

<tr>
<td>5</td>
<td>Bicycle</td>
</tr>

<tr>
<td>3</td>
<td>John</td>
</tr>

</table>


<table id="table2">

<tr>
<td>5</td>
<td>Bicycle</td>
</tr>

<thead>
<tr>
<td>6</td>
<td>Banana</td>
</tr>
</thead>

<tr>
<td>3</td>
<td>John</td>
</tr>

</table>
</body></html>










-------------------------------


import java.util.ArrayList;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlTable;
import com.gargoylesoftware.htmlunit.html.HtmlTableCell;
import com.gargoylesoftware.htmlunit.html.HtmlTableRow;

public class HtmlTableBug {

    public static void main( String args[] )
    throws Exception
    {
        final WebClient webClient = new WebClient();
        final HtmlPage page = webClient.getPage( "file:///test.html" );
       
        final ArrayList<HtmlElement> tables = new ArrayList<HtmlElement>(
page.getElementsByTagName("table") );
        for( final HtmlElement tableElement : tables ) {
            ArrayList<HtmlTableRow> allRows = new ArrayList<HtmlTableRow>(
((HtmlTable)tableElement).getRows() );
            for( final HtmlTableRow row : allRows ) {
                for( final HtmlTableCell cell : row.getCells() ) {
                        System.out.print( cell.asText() + "|" );
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user