0

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>
2
  • where does this xml come from? Is it being selected from a table (and in fact you're looping through multiple rows) or is it a single xml document that's being passed into a pl/sql procedure? Commented Nov 21, 2016 at 11:29
  • It comes from SAP. It's single xml document with a row. Commented Nov 21, 2016 at 13:50

1 Answer 1

1

Your xml isn't xml. :)

XML Naming Rules XML elements must follow these naming rules:

  • Element names are case-sensitive
  • Element names must start with a letter or underscore
  • Element names cannot start with the letters xml (or XML, or Xml, etc)
  • Element names can contain letters, digits, hyphens, underscores, and periods
  • Element names cannot contain spaces

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')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.