I need to extract data in PLSQL procedure from XMLType variable containing complete XML document, with following structure (below simplified):
<?xml version="1.0" encoding="utf-8"?>
<AA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://my.domain/cat1/">
<Element>
<ID>2</ID>
<Value>46544</Value>
<Element>
</AA>
I'm using XMLTable function, but with simple /AA/Element
XPath expression getting no data:
SELECT C1, C2
INTO v_id, v_val
FROM XMLTable('/AA/Element'
passing v_MyXML columns
C1 number path 'ID',
C2 number path 'Value'
)
Neither with any of below expressions:
'/*.AA/Element'
'declare default element namespace "http://my.domain/cat1/"; /AA/Element'
'declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance"; declare namespace xsd="http://www.w3.org/2001/XMLSchema"; declare default element namespace "http://jpk.mf.gov.pl/wzor/2016/03/09/03094/"; /AA/Element'
Only way I was able to extract the data was to modify document/variable and simply replace
<AA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://my.domain/cat1/">
with
<AA>
It's not the perfect solution as I need to modify the document and return it's initial structure with proper attributes.
Could anybody suggest how to modify XPath expression to be able to fetch data?
Or maybe use any other method ignoring namespaces from AA element?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…