Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Remove HTML via PL/SQL
Gene Hubert wrote:
>
> I seem to have the opposite problem from most of the world. I've got
> static HTML stored in Oracle 8.0.5 and would like to produce a version
> of the same data with all the HTML stuff removed.
>
> Is there an existing tool that will do this? The HTML I'm working
> with is relatively simple i.e. no frames and no javascript. The data
> I want to convert is less than 32K in size.
>
> Any advice, sample code, etc. much appreciated.
Gene,
I don't know if there is a tool that does what you want. By "removing" HTML I take it you mean remove all the <TAG> </TAG> type stuff?
The way I'd do it would be to write a function along these lines:
FUNCTION remove_html (v_text IN VARCHAR2) RETURN VARCHAR2 IS
v_count INTEGER; -- used to loop thru text containing HTML v_char CHAR(1); -- holds current character in loop v_result VARCHAR2(32000); -- holds result stripped of HTML codenot_html BOOLEAN := TRUE; -- toggle when between HTML and non-HTML mode
BEGIN FOR v_count IN 1 .. length(v_text) LOOP
v_char := SUBSTR(v_text, v_count, 1); -- get current char
There are a few limitations:
- only works with varchar or char variables - could be optimised - doesn't replace <BR> tags with carriage returns - doesn't deal with nested '<' '>' characters
I hope it helps,
Regards,
Rudi Received on Tue Jul 27 1999 - 08:29:23 CDT