CREATE OR REPLACE FUNCTION isWellFormed (xmlfile CLOB) Return BOOLEAN IS
parser xmlparser.Parser;
error varchar2(200);
XMLParseError EXCEPTION;
BEGIN
— create a parser
parser := xmlparser.newParser;
— parse the XML document
xmlparser.ParseCLOB(parser,xmlfile);
— free the parser
xmlparser.freeParser(parser);
return true;
EXCEPTION
WHEN XMLParseError THEN
xmlparser.freeParser(parser);
error := SQLERRM;
dbms_output.put_line(error);
return false;
END isWellFormed;
/
How to check an XML file is well formed in Oracle