XML (XMLType) inside PL/SQL Oracle 9/10

The XMLType is an OO XML aware data type. It can be used in columns or in PL/SQL just like VARCHAR2 or DATE. XMLType has member functions that allow access to data using XPath.

A quick example extracting a specific value from an XML varchar2 string:
DECLARE
v VARCHAR2(32000) := 'ABC';
x XMLType;
BEGIN
x := XMLType(v);
DBMS_OUTPUT.put_line(
x.extract('/DATA/LINE[1]').getStringVal()
);
DBMS_OUTPUT.put_line(
x.extract('/DATA/LINE[1]/text()').getStringVal()
);
END;

Comments

jAntoni said…
It was really very useful.
very simple and understandable complared to other examples in different sites.

Popular posts from this blog

Regular Expressions in .Net

XML documentation in Visual Basic.NET applications

MSDN TV Episode talks about "Data Access in ASP.NET 2.0"