我有從Oracle原子提要返回的xml,我暫時將其存儲在名爲'ATOM'的apex_collection中。使用Oracle SQL解析XML內部的JSON
的XML看起來是這樣的:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>atomserver:newhire:feed</id>
<title type="text">New Hire</title>
<link href="https://ucf1-fap1273-hcm.oracledemos.com/hcmCoreApi/atomservlet/employee/newhire" rel="self" />
<updated>2013-12-16T18:17:56.108Z</updated>
<entry>
<link href="https://ucf1-fap1273-hcm.oracledemos.com/hcmCoreApi/atomservlet/employee/newhire/EMP300000133185858" rel="edit" />
<id>atomservlet:newhire:EMP300000133185858</id>
<title type="text">Ford, Laura Hired</title>
<updated>2016-10-20T12:45:03.000Z</updated>
<author>
<name>BETTY.ANDERSON</name>
</author>
<summary type="text">Employee Period of Service Created</summary>
<published>2016-10-20T12:45:03.000Z</published>
<link href="https://ucf5-fap0357-hcm.oracledemos.com:443/hcmCoreApi/resources/latest/emps?q=PersonId=300000133184715&effectiveDate=2015-01-01" rel="related" />
<content type="text">{ "Context" : [ { "PrimaryPhoneNumber" : "44 1 781895862", "PersonId" : "300000133184715", "PersonName" : "Ford, Laura", "EffectiveStartDate" : "2015-01-01", "EffectiveDate" : "2015-01-01", "WorkerType" : "EMP", "PeriodType" : "E", "PersonNumber" : "3686", "WorkEmail" : "[email protected]" } ] }</content>
</entry>
</feed>
到目前爲止,我的SQL查詢是這樣的,它工作正常:
with t as (select clob001 from apex_collections where collection_name = 'ATOM')
SELECT title, summary, content FROM t,
XMLTable(XMLNamespaces(
'http://www.w3.org/2005/Atom' AS "ns0"
), 'ns0:feed/ns0:entry'
PASSING XMLTYPE.createXML(t.CLOB001)
COLUMNS title VARCHAR2(4000) path 'ns0:title' ,
summary VARCHAR2(240) path 'ns0:summary',
content VARCHAR2(4000) path 'ns0:content');
,但我需要的信息即在內容標籤內顯示,就好像它的JSON一樣。我知道如何用SQL解析JSON,但我不知道如何解析JSON,如果它在XML文檔中。
我不理解。此時'content'已經從XML中提取爲關係數據。那麼,爲什麼你不能用你已有的方法來解析? Whact在你嘗試時發生? –
內容標籤的內容是JSON。所以如果我想標題,摘要和WorkEmail我想要做這樣的事情:用t as(從apex_collections其中collection_name ='ATOM'選擇clob001)選擇標題,摘要,content.Context [0] .WorkEmail FROM ... .etc等,但是拋出我ORA-00923:FROM關鍵字找不到預期的地方。 –