Mencari kueri 'sempurna' mungkin sia-sia; browser (termasuk browser teks, seperti yang direkomendasikan di tempat lain) telah menghabiskan waktu bertahun-tahun untuk menyelesaikan semua kekusutan dan kasus tepi.
Jika Anda benar-benar tidak dapat menggunakan sumber daya eksternal, Anda dapat menjalankan DOM melalui dbms_xmldom
kemasan. Berikut demo menggunakan blok anonim dan nilai sampel Anda, yang dicetak ke layar (jika Anda mengaktifkannya); tetapi Anda dapat dengan mudah menyesuaikannya dengan fungsi yang mengembalikan CLOB, atau apa pun yang Anda butuhkan sebagai hasil akhir.
set serveroutput on
set define off
declare
l_element xmldom.domelement;
l_document xmldom.domdocument;
l_text clob;
procedure print_node (p_node xmldom.domnode) is
l_nodes dbms_xmldom.domnodelist;
begin
-- print out any plain text
if dbms_xmldom.getnodetype(p_node) = 3
and dbms_xmldom.getnodename(p_node) = '#text' then
dbms_output.put_line(dbms_xmldom.getnodevalue(p_node));
end if;
-- just to match your expected output, add a blank line for p tags
if dbms_xmldom.getnodetype(p_node) = 1
and dbms_xmldom.getnodename(p_node) = 'p' then
dbms_output.new_line;
end if;
-- get any child nodes
l_nodes := dbms_xmldom.getchildnodes(p_node);
-- process each node in turn, recursively
for i in 0..dbms_xmldom.getlength(l_nodes) - 1 loop
print_node(dbms_xmldom.item(l_nodes, i));
end loop;
end print_node;
begin
l_text := '<p>NAME: XXX<br />Company Name: YYYYY<br />Location: ZZZ, 22 Z1Z1Z1, Z2Z2Z2,Z3Z3Z3, 0000024, IND<br />Type: PrePA<br />Team: Team1, Dues tamble <br />Date: January 25 – 26, 2016<br />Rating: Tr 2<br />Number: 8554342</p>
<p><u>Observ: <br /></u>There were (6) major and (2) minor .<br /> <br />MAJOR</p><ul> <li>Sample Text_1.</li> <li>Sample Text_2.</li>
<li>Sample Text_33.</li> <li>Sample Text_4.</li> <li>Sample Text_5.</li></ul><p>MINOR</p><ul> <li>Sample Text_7</li>
<li>Sample Text_8<br /> </li></ul><p><b> Background</b><br /> </p>';
-- wrap the fragment in a root node so it parses, and run through
-- utl_i18n.unescape_reference to get rid of etc.
l_document := dbms_xmldom.newdomdocument('<html>'
|| utl_i18n.unescape_reference(l_text) || '</html>');
-- get the root element (which is now the added html)
l_element := dbms_xmldom.getdocumentelement(l_document);
-- call the recursive procedure to process this node
print_node(dbms_xmldom.makenode(l_element));
end;
/
Yang menghasilkan:
NAME: XXX
Company Name: YYYYY
Location: ZZZ, 22 Z1Z1Z1, Z2Z2Z2,Z3Z3Z3, 0000024, IND
Type: PrePA
Team: Team1, Dues tamble
Date: January 25 – 26, 2016
Rating: Tr 2
Number: 8554342
Observ:
There were (6) major and (2) minor .
MAJOR
Sample Text_1.
Sample Text_2.
Sample Text_33.
Sample Text_4.
Sample Text_5.
MINOR
Sample Text_7
Sample Text_8
Background