首先,将 XML 存储在XMLType
列中可能会更容易。否则,为了解析数据,您必须在运行时将 转换CLOB
为。XMLType
但是,假设您从 a 开始CLOB
,您应该能够执行类似的操作
select xmltype( xml_response ).extract('//stat/text()',
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" ' ||
'xmlns="http://xmlns.oracle.com/orawsv/DBUSER/MYSERV').getStringVal()
from foo
提取数据。对于我的测试,我创建了一个表CLOB
SQL> create table foo(
2 xml_response clob
3 );
Table created.
插入您的示例数据
SQL> insert into foo values( '<?xml version="1.0" ?>
2 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3 <soap:Body>
4 <GET_PERMITOutput xmlns="http://xmlns.oracle.com/orawsv/DBUSER/MYSERV">
5 <RETURN>
6 <STATUS_CODES>
7 <stat>REC</stat>
8 </STATUS_CODES>
9 </RETURN>
10 </GET_PERMITOutput>
11 </soap:Body>
12 </soap:Envelope>');
1 row created.
然后编写查询来提取它
SQL> ed
Wrote file afiedt.buf
1 select xmltype( xml_response ).extract('//stat/text()',
2 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" ' ||
3 'xmlns="http://xmlns.oracle.com/orawsv/DBUSER/MYSERV').getStringVal()
4* from foo
SQL> /
XMLTYPE(XML_RESPONSE).EXTRACT('//STAT/TEXT()','XMLNS:SOAP="HTTP://SCHEMAS.XMLSOA
--------------------------------------------------------------------------------
REC