如何在oracle中提取包含名称空间的XML数据

时间:2017-05-05 05:15:38

标签: xml oracle

查询:

select * from xmltable(XMLNAMESPACES('http://test/asdf/bean' as "bean",  
default 'http://example.org/SCL/CommonTypes') , '/bean:TransactionData/TransactionRequest/CustomerId'  
passing xmltype('<ns:TransactionData xmlns:ns="http://test/asdf/bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns:TransactionData">
        <TransactionRequest xmlns:nste="http://pegasus/component/payment/bean" xsi:type="nste:bankTransferRequest">
                <CustomerId>0001</CustomerId>
                <Account>12332131321331</Account>
                <Currency>MMK</Currency>
                <Reference>83550 test</Reference>
        </TransactionRequest>
</ns:TransactionData>'));

1 个答案:

答案 0 :(得分:1)

试试这个:

<ion-list>
    <button ion-item [ngClass]="configop.selection" *ngFor="let configop of detail" (click)="itemSelected(configop)" >
        <div class="ion-item optionalItem">
            <div class="ion-button">
                <span class="color-code" >
                    <img src="{{configop.image}}">
                    </span>
                    <span class="color-name">{{ configop.name }}</span>
                <span class="color-price">{{ configop.price|currency:'PKR':false }}</span>
            </div>
        </div>
    </button>
</ion-list>

.ts file
    itemSelected(configop: any) {
      if(this.selection !=null){
        if(configop.name == this.selection){
          this.storage.remove('carPaint');
          this.selection=configop.name;
        }
        else {
          this.storage.remove('carPaint');
          this.storage.set('carPaint', configop);
          this.selection=configop.name;}
        }
        else {
          this.storage.set('carPaint', configop);
          this.selection=configop.name;}
        }

如果要使用bean作为名称空间前缀:

select t.* from xmltable(XMLNAMESPACES('http://test/asdf/bean' as "ns") 
,'//ns:TransactionData/TransactionRequest/CustomerId'
 passing xmltype('<ns:TransactionData xmlns:ns="http://test/asdf/bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns:TransactionData">
        <TransactionRequest xmlns:nste="http://pegasus/component/payment/bean" xsi:type="nste:bankTransferRequest">
                <CustomerId>0001</CustomerId>
                <Account>12332131321331</Account>
                <Currency>MMK</Currency>
                <Reference>83550 test</Reference>
        </TransactionRequest>
</ns:TransactionData>')) as t

使用Oracle 12.1和SQLplus的示例输出。

select t.* from xmltable(XMLNAMESPACES('http://test/asdf/bean' as "bean") 
,'//bean:TransactionData/TransactionRequest/CustomerId'
 passing xmltype('<ns:TransactionData xmlns:ns="http://test/asdf/bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns:TransactionData">
        <TransactionRequest xmlns:nste="http://pegasus/component/payment/bean" xsi:type="nste:bankTransferRequest">
                <CustomerId>0001</CustomerId>
                <Account>12332131321331</Account>
                <Currency>MMK</Currency>
                <Reference>83550 test</Reference>
        </TransactionRequest>
</ns:TransactionData>')) as t