如何在Oracle中解析XML数组

时间:2019-07-16 05:02:11

标签: sql xml oracle parsing xmltype

我有一个带有accounts数组的xml,如果该数组具有1个帐户,则此代码可以正常工作,但是如果该数组具有多个帐户,则此代码不起作用。请帮忙。

select x.acc_num --into res
from xmltable (
  xmlnamespaces (
      default 'http://www.eubank.kz/Bis.Info.ExternalServices.Bank',
      'http://schemas.xmlsoap.org/soap/envelope/' AS "s",
      'http://www.w3.org/2001/XMLSchema-instance' as "i",
      'http://schemas.microsoft.com/2003/10/Serialization/Arrays' as "a"
  ),
  's:Envelope/s:Body/TryGetCardAccountsResponse/TryGetCardAccountsResult/IbanList'
  passing xmltype(
  '<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <TryGetCardAccountsResponse
            xmlns="http://www.eubank.kz/Bis.Info.ExternalServices.Bank">
            <TryGetCardAccountsResult
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <IbanList
                    xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                    <a:string>KZ199480018A00166666</a:string>
                    <a:string>KZ519480061A02366666</a:string>
                </IbanList>
                <Status>Ok</Status>
            </TryGetCardAccountsResult>
        </TryGetCardAccountsResponse>
    </s:Body>
</s:Envelope>'
  )
  columns
    acc_num varchar2(255) path 'a:string'
) x;

1 个答案:

答案 0 :(得分:0)

尝试:

body {margin: 2% 2%; }
#q1 {margin: 10px 10px; border: 1px; box-shadow: 0px 2px 2px 2px #DCDCDC; text-align: left; padding: 5px 20px; font-size: 18px;  color: #ffffff; background-color: #317eac;}
#a1 {margin: 10px 10px; border: 1px; padding: 10px;  box-shadow: 0px 2px 2px 2px #DCDCDC;  text-align: left;font-size: 16px;  padding: 8px 18px;}
#a2 {margin: 10px 10px;  border: 1px; box-shadow: 0px 2px 2px 2px #DCDCDC;  text-align: left;  padding: 5px 18px;  font-size: 16px;}
#a1:hover{color: #ffffff; background-color: #73AD21;}
#a2:hover{color: #ffffff; background-color: #C71C22;}