我試圖從xmltype
文檔中提取xml。如何在xml中提取xml在Oracle中
DECLARE
xmlData XMLType;
sDocumentId VARCHAR2(100);
sFormat VARCHAR2(100);
cData CLOB;
BEGIN
xmlData := XMLType('<main>
<document_id>1234567</document_id>
<format>E66</format>
<data><Fname>ABCD</Fname><Lname>EFGD</Lname></data>
</main>');
SELECT ExtractValue(xmlData, '/main/document_id/text()'),
ExtractValue(xmlData, '/main/format/text()'),
ExtractValue(xmlData, '/main/data/text()')
INTO sDocumentId,
sFormat,
cData
FROM (SELECT xmlData FROM DUAL);
dbms_output.put_line(sDocumentId);
dbms_output.put_line(sFormat);
dbms_output.put_line(cData);
END;
如何得到的輸出是這樣的:
- DocumentId =
1234567
- sFormat =
E66
- CDATA =
<Fname>ABCD</Fname><Lname>EFGD</Lname>
xmlData.Extract( '/主/數據/文本()')getStringVal()讓你' ABCD EFGD '接近,但不夠緊密;) –
booyaa
想出了這確實得到XML片段:'提取物(XMLDATA, '/主/數據/節點()')getStringVal()' – booyaa