Reputation: 9
I am new to XML and XML Schema. I want to extract the customer id and customer name from the following XML pass these two values to PL/SQL procedure. Could you please help me on this? Thanks in advance.
XML:
<?xml version="1.0" encoding="UTF-8"?>
-<ns0:NewConnection xmlns:ns0="http://xyz.co.uk/cust">
<Customer>SA02121</Customer>
<Customer name>John</Customer name>
<Load Date>2016-11-09</Load Date>
<Load Time>03:40:12</Load Time>
</ns0:NewConnection>
Upvotes: 0
Views: 326
Reputation: 6346
Your xml isn't xml. :)
XML Naming Rules XML elements must follow these naming rules:
If your replace sapces with underscore in your tags. You can obtain data using xmltabel.
select *
from xmltable(xmlnamespaces('http://xyz.co.uk/cust' as "ns0"), '/ns0:NewConnection'
passing xmltype('<?xml version="1.0" encoding="UTF-8"?>
<ns0:NewConnection xmlns:ns0="http://xyz.co.uk/cust">
<Customer>SA02121</Customer>
<Customer_name>John</Customer_name>
<Load_Date>2016-11-09</Load_Date>
<Load_Time>03:40:12</Load_Time>
</ns0:NewConnection>')
columns Customer varchar2(200) path 'Customer'
, Customer_name varchar2(200) path 'Customer_name'
, Load_Date varchar2(200) path 'Load_Date'
, Load_Time varchar2(200) path 'Load_Time')
Upvotes: 1