1 Attachment(s)
Parse THIS!!! XML can't contain HTML (anchor tags)???
Is there a way to parse XML that has HTML tags and special characters within it?
I've been searching for days for a solution with no joy.
The Oracle scripts I wrote below work fine as long as only alphanumeric characters are in the XML doc.
Here's what I'm doing...I'm page scraping several dynamic websites using ColdFusion. I remove all the unneeded HTML...and replace the remaining HTML with XML tags.
I then want to pass this XML (attached txt file) variable (cfxml) to Oracle so it can be parsed and loaded into the database. If I remove the anchor tags and the CDATA tags...the code works fine....but I want the anchor tags loaded into my table.
Anyone have any suggestions....preferably a solution so I can stop pulling my damn hair out.
---------------------------------------------------------
Oracle Scripts
---------------------------------------------------------
create or replace procedure LoadXML (cfxml in varchar) AS
begin
insert into JOBS (xmldoc) values
(xmltype.createxml(cfxml));
end;
create or replace trigger job_bifert as
begin
if (:new.xmldoc is null) then
return;
end if;
select
xmltype.getstringval(:new.xmldoc.extract('/recordset/row/title/text()')),
xmltype.getstringval(:new.xmldoc.extract('/recordset/row/company/text()')),
xmltype.getstringval(:new.xmldoc.extract('/recordset/row/location/text()'))
into :new.title, :new.company, :new.location
from dual;
end;
1 Attachment(s)
Scripts, Examples....Errs, Etc.
Tim,
Thanks for responding. Below is the table (JOBs) I want to insert records.
CREATE TABLE JOBS
(
ID NUMBER,
HOST VARCHAR2(100 BYTE),
SEARCH VARCHAR2(100 BYTE),
LINK VARCHAR2(4000 BYTE),
POSTDATE DATE,
TITLE VARCHAR2(4000 BYTE),
COMPANY VARCHAR2(4000 BYTE),
LOCATION VARCHAR2(100 BYTE),
D_UPD DATE,
STATE VARCHAR2(100 BYTE),
CITY VARCHAR2(100 BYTE),
TITLE_NOLINK VARCHAR2(100 BYTE),
COMPANY_NOLINK VARCHAR2(100 BYTE),
XMLDOC SYS.XMLTYPE
)
Like I was saying...when I try to use the SP and Trigger in Ex 1...everything works fine. Ex 2 doesn't work (see attachment).
Any ideas why???
1 Attachment(s)
Nope....still get the error
Nope...didn't work.
I even tried changing it to a CLOB (see below + attachment).
Still getting this error.
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "SASSOH.JOBS_BIFERT", line 5
ORA-04088: error during execution of trigger 'SASSOH.JOBS_BIFERT'
ORA-06512: at "SASSOH.LOADXML", line 3
ORA-06512: at line 22
When I take out the anchor tags and the CDATA, everything works perfectly.
--------------------------------------------------------------
CREATE OR REPLACE PROCEDURE LoadXML (cfxml in CLOB) AS
begin
insert into JOBS (xmldoc) values (xmltype.createxml(cfxml));
end;
/