Available in versions: Dev (3.22) | Latest (3.21) | 3.20 | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12
This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
Reading HTML
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
DSLContext.fetchFromHTML() is the inverse operation of exporting HTML. It parses an HTML table into a Result<Record>:
Result<Record> result = create.fetchFromHTML(
"<table>"
+ " <tr><th>ID</th><th>AUTHOR_ID</th><th>TITLE</th></tr>"
+ " <tr><td>1</td><td>1</td><td>1984</td></tr>"
+ " <tr><td>2</td><td>1</td><td>Animal Farm</td></tr>"
+ "</table>"
);
The input must be well-formed XML, but doesn't have to be valid XHTML. The following rules apply:
- Elements and attributes other than
<table>,<tr>,<th>, and<td>(e.g.<thead>or<tbody>), as well as comments, are ignored. - The
<table>element is optional, and may appear at most once. Nested tables are not supported. - The first row containing
<th>elements defines the field names. Without such a row, field names are generated. - The first row defines the number of columns. Shorter subsequent rows are padded, longer ones are truncated.
All fields of the resulting Result are of type String. See the section about working with in-memory results to learn how to convert such results to other types.
Feedback
Do you have any feedback about this page? We'd love to hear it!