How to Convert a Table into XML Document

oracleoracle-11g-r2xml

I have a table say SCOTT.DEPT and I want to convert it into an XML document. Is there anyway to accomplish this task?

Kind Regards,

Best Answer

The easiest way to do this is:

select dbms_xmlgen.getxml( 'select * from dept') as xml 
from dual;

There are other way more complicated ways of achieving similar results, but the answer would be significantly longer!