2017-11-17 1 views
1

ich nicht in der Lage bin Werte aus dem XML unter 2012. Bitte helfen Sie in SQL Server gezeigt zu holensoapenv Parsing Fehler

<soapenv:Envelope xmlns:soapenv="http://schemas.abc.org/soap/envelope/" xmlns:wsap="http://schemas.abc.com/abcd"> 
    <soapenv:Header xmlns:wsap="http://schemas.abc.com/abcd" xmlns:soapenv="http://schemas.example.org/soap/envelope/"> 
    <header xmlns:wsap="http://schemas.abc.com/abcd" xmlns:soapenv="http://schemas.example.org/soap/envelope/" xmlns="http://schemas.abc.com/General/1.0/"> 
     <msg-id>0673c07b-2b67-11e7-f959-0b3aae0b96ad</msg-id> 
    </header> 
    </soapenv:Header> 
    <soapenv:Body> 
    <GetInvoice_DataResponse xmlns:soapenv="http://schemas.example.org/soap/abcd/" xmlns="http://schemas.abc.com/abcd" preserveSpace="no" qAccess="0"> 
     <tuple xmlns="http://schemas.abc.com/abcd"> 
     <old> 
      <S_ORDER xmlns="http://schemas.abc.com/abcd"> 
      <BILLING_TYPE>Paid</BILLING_TYPE> 
      <CREATED>2017-11-13T10:40:28.0</CREATED> 
      <CREATED_BY>1-455454asdas</CREATED_BY> 
      <LAST_UPD>2017-11-13T10:40:29.0</LAST_UPD> 
      <LAST_UPD_BY>1-dsafasc</LAST_UPD_BY> 
      <INVC_DT>2017-11-13T00:00:00.0</INVC_DT> 
      <INVC_NUM>dasda123</INVC_NUM> 
      <STATUS_CD>New</STATUS_CD> 
      <X_CANCELLATION_REASON xmlns:xsi="http://www.example.org/2001/exap-example" null="true" xsi:nil="true" /> 
      <GROSS_AMT>1768</GROSS_AMT> 
      <ITEM_DTL_AMT>1381.25</ITEM_DTL_AMT> 
      <ACCNT_ID>1-sad</ACCNT_ID> 
      <ORDER_ID>1-fasdf</ORDER_ID> 
      <GROSS_AMT>1768</GROSS_AMT> 
      <DIV_ID>1-fas</DIV_ID> 
      <ORDER_NUM>Osasaasf</ORDER_NUM> 
      <PART>264731200101</PART> 
      <ORDER_DT>20171113</ORDER_DT> 
      <INVOICE_DT>20171113</INVOICE_DT> 
      <ORDER_TYPE>ads fd</ORDER_TYPE> 
      <QTY>1</QTY> 
      <LINE_NUM>1</LINE_NUM> 
      <INVC_STATUS>New</INVC_STATUS> 
      <LINE_ITEM_STATUS>Invoiced</LINE_ITEM_STATUS> 
      <BU>CVBU</BU> 
      </S_ORDER> 
     </old> 
     </tuple> 
     <tuple xmlns="http://schemas.abc.com/abcd"> 
     <old> 
      <S_ORDER xmlns="http://schemas.abc.com/abcd"> 
      <BILLING_TYPE>Paid</BILLING_TYPE> 
      <CREATED>2017-11-13T10:40:28.0</CREATED> 
      <CREATED_BY>1-das</CREATED_BY> 
      <LAST_UPD>2017-11-13T10:40:29.0</LAST_UPD> 
      <LAST_UPD_BY>1-safdfa</LAST_UPD_BY> 
      <INVC_DT>2017-11-13T00:00:00.0</INVC_DT> 
      <INVC_NUM>afsfas415415</INVC_NUM> 
      <STATUS_CD>New</STATUS_CD> 
      <X_CANCELLATION_REASON xmlns:xsi="http://www.example.org/2001/exap-example" null="true" xsi:nil="true" /> 
      <GROSS_AMT>1768</GROSS_AMT> 
      <ITEM_DTL_AMT>0</ITEM_DTL_AMT> 
      <ACCNT_ID>1-fasf</ACCNT_ID> 
      <ORDER_ID>1-saf</ORDER_ID> 
      <GROSS_AMT>1768</GROSS_AMT> 
      <DIV_ID>1-1IJGRE5</DIV_ID> 
      <ORDER_NUM>fasf-sf-s-fd-gd</ORDER_NUM> 
      <PART>0000079641</PART> 
      <ORDER_DT>20171113</ORDER_DT> 
      <INVOICE_DT>20171113</INVOICE_DT> 
      <ORDER_TYPE>fasdf d</ORDER_TYPE> 
      <QTY>1</QTY> 
      <LINE_NUM>2</LINE_NUM> 
      <INVC_STATUS>New</INVC_STATUS> 
      <LINE_ITEM_STATUS>Invoiced</LINE_ITEM_STATUS> 
      <BU>CVBU</BU> 
      </S_ORDER> 
     </old> 
     </tuple> 
    </GetInvoice_DataResponse> 
    </soapenv:Body> 
</soapenv:Envelope> 
+0

Ich brauche Werte von BILLING_TYPE, CREATED, usw., die in S_ORDER sind – jitu

+0

Zeigen Sie uns Ihren Code so weit! Was hast du probiert? Erhalten Sie Fehler - wenn ja: ** was ** Fehler? (Denken Sie daran: wir Ihren Bildschirm nicht lesen können, noch dein Geist - Sie haben US ** SHOW **) –

+0

Hallo Marc, ich versuchte wie unten- \t \t \t \t \t SELECT NCvalue ('(BILLING_TYPE zu lesen [1 ]) ',' nvarchar (80) '), NCvalue (' (CREATED [1]) ',' datetime '), NC-Wert (' (CREATED_BY [1]) ',' varchar (50) ') , NCvalue ('(LAST_UPD_BY [1])', 'VARCHAR (50)'), NCvalue ('(INVC_DT [1])', ' Datumzeit von @ pXMLFile.nodes ('/GetInvoice_DataResponse/tuple/alt/S_ORDER ') N (C) – jitu

Antwort

1

Wenn Sie Ihre XML in einer @Input Variable vom Typ XML haben, können Sie versuchen, diese :

-- define your XML namespaces used in the XML document 
;WITH XMLNAMESPACES ('http://schemas.abc.org/soap/envelope/' AS soapenv, 
        'http://schemas.abc.com/abcd' AS inv) 
SELECT 
    -- "reach into" the XML fragment representing the "<S_ORDER>" element 
    -- and get the individual subelements from it - using the *default* 
    -- XML namespace for those subelements 
    BillingType = xc.value('(inv:BILLING_TYPE)[1]', 'varchar(50)'), 
    Created = xc.value('(inv:CREATED)[1]', 'varchar(50)') 
FROM 
    -- define the path down to the "<S_ORDER>" elements, and fetch 
    -- an "in-memory" table of each of those elements as a XML fragment 
    @input.nodes('/soapenv:Envelope/soapenv:Body/inv:GetInvoice_DataResponse/inv:tuple/inv:old/inv:S_ORDER') AS XT(XC) 

Der wichtigste Punkt ist: Sie müssen Respekt und umfassen die XML-Namespaces in Ihrem XQuery!

+1

Vielen Dank. Es half – jitu