【发布时间】:2017-07-27 10:46:03
【问题描述】:
我需要创建 HTML 表格解析器,它将以正确的顺序读取表格单元格。
到目前为止我的代码:
html := '<body>
<table border="1">
<tr>
<td><b>A1</b></td>
<td><i>B1</i></td>
</tr>
<tr>
<td><b>A2</b></td>
<td><i>B2</i></td>
</tr>
</table>
</body>';
FOR r IN (SELECT rownum rn, td FROM xmltable('*/table/tr' passing xmltype(html)
columns td xmltype path './td'))
LOOP
FOR c IN (SELECT cell FROM xmltable('.' passing r.td
columns cell VARCHAR(200) path '.'))
LOOP
dbms_output.put_line('Row ' || r.rn || ': ' || c.cell);
END LOOP;
END LOOP;
现在结果是:
Row 1: A1B1
Row 2: A2B2
我需要的是:
Row 1: A1
Row 1: B1
Row 2: A2
Row 2: B2
我怎样才能做到这一点?感谢您的回复。
【问题讨论】:
标签: html xml plsql xml-parsing html-table