Как получить данные из XML с большим количеством префиксов / пространств имен - PullRequest
0 голосов
/ 26 февраля 2019

Я новичок в XML и не могу понять структуру XML, которую можно использовать для получения данных для вставки в таблицу в SQL.Можете ли вы помочь мне показать, как это сделать?

Мне нужны детали из элемента intDocItem, я всегда получаю нулевое значение или 0 в результате.

Вот часть XML-файла:

<?xml version="1.0" encoding="Windows-1250"?>
<rsp:responsePack version="2.0" id="Usr01" state="ok" programVersion="12103.2 (4.2.2019)" ico="63321238" key="1b6b2094-5b4b-4009-8746-9446b70218fb" note="Uživatelský export" xmlns:rsp="http://www.stormware.cz/schema/version_2/response.xsd" xmlns:rdc="http://www.stormware.cz/schema/version_2/documentresponse.xsd" xmlns:typ="http://www.stormware.cz/schema/version_2/type.xsd" xmlns:lst="http://www.stormware.cz/schema/version_2/list.xsd" xmlns:lStk="http://www.stormware.cz/schema/version_2/list_stock.xsd" xmlns:lAdb="http://www.stormware.cz/schema/version_2/list_addBook.xsd" xmlns:lCen="http://www.stormware.cz/schema/version_2/list_centre.xsd" xmlns:lAcv="http://www.stormware.cz/schema/version_2/list_activity.xsd" xmlns:acu="http://www.stormware.cz/schema/version_2/accountingunit.xsd" xmlns:inv="http://www.stormware.cz/schema/version_2/invoice.xsd" xmlns:vch="http://www.stormware.cz/schema/version_2/voucher.xsd" xmlns:int="http://www.stormware.cz/schema/version_2/intDoc.xsd" xmlns:stk="http://www.stormware.cz/schema/version_2/stock.xsd" xmlns:ord="http://www.stormware.cz/schema/version_2/order.xsd" xmlns:ofr="http://www.stormware.cz/schema/version_2/offer.xsd" xmlns:enq="http://www.stormware.cz/schema/version_2/enquiry.xsd" xmlns:vyd="http://www.stormware.cz/schema/version_2/vydejka.xsd" xmlns:pri="http://www.stormware.cz/schema/version_2/prijemka.xsd" xmlns:bal="http://www.stormware.cz/schema/version_2/balance.xsd" xmlns:pre="http://www.stormware.cz/schema/version_2/prevodka.xsd" xmlns:vyr="http://www.stormware.cz/schema/version_2/vyroba.xsd" xmlns:pro="http://www.stormware.cz/schema/version_2/prodejka.xsd" xmlns:con="http://www.stormware.cz/schema/version_2/contract.xsd" xmlns:adb="http://www.stormware.cz/schema/version_2/addressbook.xsd" xmlns:prm="http://www.stormware.cz/schema/version_2/parameter.xsd" xmlns:lCon="http://www.stormware.cz/schema/version_2/list_contract.xsd" xmlns:ctg="http://www.stormware.cz/schema/version_2/category.xsd" xmlns:ipm="http://www.stormware.cz/schema/version_2/intParam.xsd" xmlns:str="http://www.stormware.cz/schema/version_2/storage.xsd" xmlns:idp="http://www.stormware.cz/schema/version_2/individualPrice.xsd" xmlns:sup="http://www.stormware.cz/schema/version_2/supplier.xsd" xmlns:prn="http://www.stormware.cz/schema/version_2/print.xsd" xmlns:sEET="http://www.stormware.cz/schema/version_2/sendEET.xsd" xmlns:act="http://www.stormware.cz/schema/version_2/accountancy.xsd" xmlns:bnk="http://www.stormware.cz/schema/version_2/bank.xsd" xmlns:sto="http://www.stormware.cz/schema/version_2/store.xsd" xmlns:grs="http://www.stormware.cz/schema/version_2/groupStocks.xsd" xmlns:acp="http://www.stormware.cz/schema/version_2/actionPrice.xsd" xmlns:csh="http://www.stormware.cz/schema/version_2/cashRegister.xsd" xmlns:bka="http://www.stormware.cz/schema/version_2/bankAccount.xsd" xmlns:ilt="http://www.stormware.cz/schema/version_2/inventoryLists.xsd" xmlns:nms="http://www.stormware.cz/schema/version_2/numericalSeries.xsd" xmlns:pay="http://www.stormware.cz/schema/version_2/payment.xsd" xmlns:mKasa="http://www.stormware.cz/schema/version_2/mKasa.xsd" xmlns:gdp="http://www.stormware.cz/schema/version_2/GDPR.xsd" xmlns:est="http://www.stormware.cz/schema/version_2/establishment.xsd" xmlns:cen="http://www.stormware.cz/schema/version_2/centre.xsd" xmlns:acv="http://www.stormware.cz/schema/version_2/activity.xsd" xmlns:ftr="http://www.stormware.cz/schema/version_2/filter.xsd"><rsp:responsePackItem version="2.0" id="Usr01" state="ok"><lst:listIntDoc version="2.0" dateTimeStamp="2019-02-20T13:39:44" dateValidFrom="2019-02-20" state="ok"><lst:intDoc version="2.0"><int:intDocHeader><int:id>9</int:id><int:number><typ:id>86</typ:id><typ:ids>19IN</typ:ids><typ:numberRequested>19IN00001</typ:numberRequested></int:number><int:symVar>1900001</int:symVar><int:symPar>MZ201901</int:symPar><int:date>2019-01-31</int:date><int:dateTax>2019-01-31</int:dateTax><int:dateAccounting>2019-01-31</int:dateAccounting><int:accounting><typ:id>241</typ:id><typ:ids>521100/331100</typ:ids></int:accounting><int:classificationVAT><typ:id>5</typ:id><typ:ids>UN</typ:ids><typ:classificationVATType>nonSubsume</typ:classificationVATType></int:classificationVAT><int:text>Mzdy 2019/01, zaúčtování mzdových nákladů - hrubá mzda</int:text><int:myIdentity><typ:address><typ:company>Minova Bohemia </typ:company><typ:title>s.r.o.</typ:title><typ:surname>Ing. Kučera</typ:surname><typ:name>Petr</typ:name><typ:city>Ostrava -Radvanice</typ:city><typ:street>Lihovarská</typ:street><typ:number>1199/10</typ:number><typ:zip>716 00</typ:zip><typ:ico>63321238</typ:ico><typ:dic>CZ63321238</typ:dic><typ:www>AKT</typ:www></typ:address></int:myIdentity><int:liquidation>false</int:liquidation><int:markRecord>false</int:markRecord></int:intDocHeader><int:intDocDetail><int:intDocItem><int:text>Hrubá mzda zaměstnance</int:text><int:quantity>1.0</int:quantity><int:coefficient>1.0</int:coefficient><int:payVAT>false</int:payVAT><int:rateVAT>none</int:rateVAT><int:discountPercentage>0.0</int:discountPercentage><int:homeCurrency><typ:unitPrice>328163</typ:unitPrice><typ:price>328163</typ:price><typ:priceVAT>0</typ:priceVAT><typ:priceSum>328163</typ:priceSum></int:homeCurrency><int:note>(zaměstnanci)</int:note><int:accounting><typ:id>241</typ:id><typ:ids>521100/331100</typ:ids></int:accounting><int:PDP>false</int:PDP><int:centre><typ:id>1</typ:id><typ:ids>10</typ:ids></int:centre><int:contract><typ:id>1</typ:id><typ:ids>10</typ:ids></int:contract></int:intDocItem><int:intDocItem><int:text>Hrubá mzda zaměstnance</int:text><int:quantity>1.0</int:quantity><int:coefficient>1.0</int:coefficient><int:payVAT>false</int:payVAT><int:rateVAT>none</int:rateVAT><int:discountPercentage>0.0</int:discountPercentage><int:homeCurrency><typ:unitPrice>283019</typ:unitPrice><typ:price>283019</typ:price><typ:priceVAT>0</typ:priceVAT><typ:priceSum>283019</typ:priceSum></int:homeCurrency><int:note>(zaměstnanci)</int:note><int:accounting><typ:id>241</typ:id><typ:ids>521100/331100</typ:ids></int:accounting><int:PDP>false</int:PDP><int:centre><typ:id>2</typ:id><typ:ids>11</typ:ids></int:centre><int:contract><typ:id>2</typ:id><typ:ids>11</typ:ids></int:contract></int:intDocItem><int:intDocItem><int:text>Hrubá mzda zaměstnance</int:text><int:quantity>1.0</int:quantity><int:coefficient>1.0</int:coefficient><int:payVAT>false</int:payVAT><int:rateVAT>none</int:rateVAT><int:discountPercentage>0.0</int:discountPercentage><int:homeCurrency><typ:unitPrice>1759</typ:unitPrice><typ:price>1759</typ:price><typ:priceVAT>0</typ:priceVAT><typ:priceSum>1759</typ:priceSum></int:homeCurrency><int:note>(zaměstnanci)</int:note><int:accounting><typ:id>241</typ:id><typ:ids>521100/331100</typ:ids></int:accounting><int:PDP>false</int:PDP><int:centre><typ:id>2</typ:id><typ:ids>11</typ:ids></int:centre><int:contract><typ:id>15</typ:id><typ:ids>51</typ:ids></int:contract></int:intDocItem><int:intDocItem><int:text>Hrubá mzda zaměstnance</int:text><int:quantity>1.0</int:quantity><int:coefficient>1.0</int:coefficient><int:payVAT>false</int:payVAT><int:rateVAT>none</int:rateVAT><int:discountPercentage>0.0</int:discountPercentage><int:homeCurrency><typ:unitPrice>253878</typ:unitPrice><typ:price>253878</typ:price><typ:priceVAT>0</typ:priceVAT><typ:priceSum>253878</typ:priceSum></int:homeCurrency><int:note>(zaměstnanci)</int:note><int:accounting><typ:id>241</typ:id><typ:ids>521100/331100</typ:ids></int:accounting><int:PDP>false</int:PDP><int:centre><typ:id>3</typ:id><typ:ids>12</typ:ids></int:centre><int:contract><typ:id>3</typ:id><typ:ids>12</typ:ids></int:contract></int:intDocItem>

Буду признателен, если вы поможете мне бороться с пространством имен для получения данных.Нужно ли сохранять определение XSD в БД?

1 Ответ

0 голосов
/ 26 февраля 2019

Во-первых, вы должны удалить <?xml ?>, вам это здесь не нужно.

Во-вторых: В следующий раз, пожалуйста, не просто вырезайте XML в конце.Лучше убрать повторяющиеся элементы посередине (достаточно двух, чтобы показать принципы).Трудно понять структуру и добавить закрывающие теги в конце.

Теперь к вашему вопросу: ваш заголовок говорит правду.Я никогда раньше не видел так много пространств имен ;-) У вас есть два подхода (и вы даже можете смешивать их):

  1. Объявите все необходимые пространства имен и используйте их имена полностью квалифицированными, или
  2. Использовать подстановочный знак пространства имен.Но это опасно, если в разных пространствах имен есть элементы с одинаковыми именами.

В целом: будьте максимально конкретны, поэтому я бы хотел объявить пространства имен:

Попробуйте это:

Declare @xml XML=
N'<rsp:responsePack xmlns:rsp="http://www.stormware.cz/schema/version_2/response.xsd" 
              xmlns:rdc="http://www.stormware.cz/schema/version_2/documentresponse.xsd"
              xmlns:typ="http://www.stormware.cz/schema/version_2/type.xsd" 
              xmlns:lst="http://www.stormware.cz/schema/version_2/list.xsd" 
              xmlns:lStk="http://www.stormware.cz/schema/version_2/list_stock.xsd" 
              xmlns:lAdb="http://www.stormware.cz/schema/version_2/list_addBook.xsd" 
              xmlns:lCen="http://www.stormware.cz/schema/version_2/list_centre.xsd" 
              xmlns:lAcv="http://www.stormware.cz/schema/version_2/list_activity.xsd" 
              xmlns:acu="http://www.stormware.cz/schema/version_2/accountingunit.xsd" 
              xmlns:inv="http://www.stormware.cz/schema/version_2/invoice.xsd" 
              xmlns:vch="http://www.stormware.cz/schema/version_2/voucher.xsd" 
              xmlns:int="http://www.stormware.cz/schema/version_2/intDoc.xsd" 
              xmlns:stk="http://www.stormware.cz/schema/version_2/stock.xsd" 
              xmlns:ord="http://www.stormware.cz/schema/version_2/order.xsd" 
              xmlns:ofr="http://www.stormware.cz/schema/version_2/offer.xsd" 
              xmlns:enq="http://www.stormware.cz/schema/version_2/enquiry.xsd" 
              xmlns:vyd="http://www.stormware.cz/schema/version_2/vydejka.xsd" 
              xmlns:pri="http://www.stormware.cz/schema/version_2/prijemka.xsd" 
              xmlns:bal="http://www.stormware.cz/schema/version_2/balance.xsd" 
              xmlns:pre="http://www.stormware.cz/schema/version_2/prevodka.xsd" 
              xmlns:vyr="http://www.stormware.cz/schema/version_2/vyroba.xsd" 
              xmlns:pro="http://www.stormware.cz/schema/version_2/prodejka.xsd" 
              xmlns:con="http://www.stormware.cz/schema/version_2/contract.xsd" 
              xmlns:adb="http://www.stormware.cz/schema/version_2/addressbook.xsd" 
              xmlns:prm="http://www.stormware.cz/schema/version_2/parameter.xsd" 
              xmlns:lCon="http://www.stormware.cz/schema/version_2/list_contract.xsd" 
              xmlns:ctg="http://www.stormware.cz/schema/version_2/category.xsd" 
              xmlns:ipm="http://www.stormware.cz/schema/version_2/intParam.xsd" 
              xmlns:str="http://www.stormware.cz/schema/version_2/storage.xsd" 
              xmlns:idp="http://www.stormware.cz/schema/version_2/individualPrice.xsd" 
              xmlns:sup="http://www.stormware.cz/schema/version_2/supplier.xsd" 
              xmlns:prn="http://www.stormware.cz/schema/version_2/print.xsd" 
              xmlns:sEET="http://www.stormware.cz/schema/version_2/sendEET.xsd" 
              xmlns:act="http://www.stormware.cz/schema/version_2/accountancy.xsd" 
              xmlns:bnk="http://www.stormware.cz/schema/version_2/bank.xsd" 
              xmlns:sto="http://www.stormware.cz/schema/version_2/store.xsd" 
              xmlns:grs="http://www.stormware.cz/schema/version_2/groupStocks.xsd" 
              xmlns:acp="http://www.stormware.cz/schema/version_2/actionPrice.xsd" 
              xmlns:csh="http://www.stormware.cz/schema/version_2/cashRegister.xsd" 
              xmlns:bka="http://www.stormware.cz/schema/version_2/bankAccount.xsd" 
              xmlns:ilt="http://www.stormware.cz/schema/version_2/inventoryLists.xsd" 
              xmlns:nms="http://www.stormware.cz/schema/version_2/numericalSeries.xsd" 
              xmlns:pay="http://www.stormware.cz/schema/version_2/payment.xsd" 
              xmlns:mKasa="http://www.stormware.cz/schema/version_2/mKasa.xsd" 
              xmlns:gdp="http://www.stormware.cz/schema/version_2/GDPR.xsd" 
              xmlns:est="http://www.stormware.cz/schema/version_2/establishment.xsd" 
              xmlns:cen="http://www.stormware.cz/schema/version_2/centre.xsd" 
              xmlns:acv="http://www.stormware.cz/schema/version_2/activity.xsd" 
              xmlns:ftr="http://www.stormware.cz/schema/version_2/filter.xsd" 

              version="2.0" id="Usr01" state="ok" programVersion="12103.2 (4.2.2019)" ico="63321238" key="1b6b2094-5b4b-4009-8746-9446b70218fb" note="Uživatelský export">
  <rsp:responsePackItem version="2.0" id="Usr01" state="ok">
    <lst:listIntDoc version="2.0" dateTimeStamp="2019-02-20T13:39:44" dateValidFrom="2019-02-20" state="ok">
      <lst:intDoc version="2.0">
        <int:intDocHeader>
          <int:id>9</int:id>
          <int:number>
            <typ:id>86</typ:id>
            <typ:ids>19IN</typ:ids>
            <typ:numberRequested>19IN00001</typ:numberRequested>
          </int:number>
          <int:symVar>1900001</int:symVar>
          <int:symPar>MZ201901</int:symPar>
          <int:date>2019-01-31</int:date>
          <int:dateTax>2019-01-31</int:dateTax>
          <int:dateAccounting>2019-01-31</int:dateAccounting>
          <int:accounting>
            <typ:id>241</typ:id>
            <typ:ids>521100/331100</typ:ids>
          </int:accounting>
          <int:classificationVAT>
            <typ:id>5</typ:id>
            <typ:ids>UN</typ:ids>
            <typ:classificationVATType>nonSubsume</typ:classificationVATType>
          </int:classificationVAT>
          <int:text>Mzdy 2019/01, zaúčtování mzdových nákladů - hrubá mzda</int:text>
          <int:myIdentity>
            <typ:address>
              <typ:company>Minova Bohemia </typ:company>
              <typ:title>s.r.o.</typ:title>
              <typ:surname>Ing. Kučera</typ:surname>
              <typ:name>Petr</typ:name>
              <typ:city>Ostrava -Radvanice</typ:city>
              <typ:street>Lihovarská</typ:street>
              <typ:number>1199/10</typ:number>
              <typ:zip>716 00</typ:zip>
              <typ:ico>63321238</typ:ico>
              <typ:dic>CZ63321238</typ:dic>
              <typ:www>AKT</typ:www>
            </typ:address>
          </int:myIdentity>
          <int:liquidation>false</int:liquidation>
          <int:markRecord>false</int:markRecord>
        </int:intDocHeader>
        <int:intDocDetail>
          <int:intDocItem>
            <int:text>Hrubá mzda zaměstnance</int:text>
            <int:quantity>1.0</int:quantity>
            <int:coefficient>1.0</int:coefficient>
            <int:payVAT>false</int:payVAT>
            <int:rateVAT>none</int:rateVAT>
            <int:discountPercentage>0.0</int:discountPercentage>
            <int:homeCurrency>
              <typ:unitPrice>328163</typ:unitPrice>
              <typ:price>328163</typ:price>
              <typ:priceVAT>0</typ:priceVAT>
              <typ:priceSum>328163</typ:priceSum>
            </int:homeCurrency>
            <int:note>(zaměstnanci)</int:note>
            <int:accounting>
              <typ:id>241</typ:id>
              <typ:ids>521100/331100</typ:ids>
            </int:accounting>
            <int:PDP>false</int:PDP>
            <int:centre>
              <typ:id>1</typ:id>
              <typ:ids>10</typ:ids>
            </int:centre>
            <int:contract>
              <typ:id>1</typ:id>
              <typ:ids>10</typ:ids>
            </int:contract>
          </int:intDocItem>
          <int:intDocItem>
            <int:text>Hrubá mzda zaměstnance</int:text>
            <int:quantity>1.0</int:quantity>
            <int:coefficient>1.0</int:coefficient>
            <int:payVAT>false</int:payVAT>
            <int:rateVAT>none</int:rateVAT>
            <int:discountPercentage>0.0</int:discountPercentage>
            <int:homeCurrency>
              <typ:unitPrice>283019</typ:unitPrice>
              <typ:price>283019</typ:price>
              <typ:priceVAT>0</typ:priceVAT>
              <typ:priceSum>283019</typ:priceSum>
            </int:homeCurrency>
            <int:note>(zaměstnanci)</int:note>
            <int:accounting>
              <typ:id>241</typ:id>
              <typ:ids>521100/331100</typ:ids>
            </int:accounting>
            <int:PDP>false</int:PDP>
            <int:centre>
              <typ:id>2</typ:id>
              <typ:ids>11</typ:ids>
            </int:centre>
            <int:contract>
              <typ:id>2</typ:id>
              <typ:ids>11</typ:ids>
            </int:contract>
          </int:intDocItem>
            <!--removed more int:intDocItem-->> 
        </int:intDocDetail>
      </lst:intDoc>
    </lst:listIntDoc>
  </rsp:responsePackItem>
</rsp:responsePack>';

- Запрос заранее объявляет пространства имен

WITH XMLNAMESPACES('http://www.stormware.cz/schema/version_2/response.xsd' AS rsp
                  ,'http://www.stormware.cz/schema/version_2/documentresponse.xsd' AS rdc
                  ,'http://www.stormware.cz/schema/version_2/type.xsd' AS typ
                  ,'http://www.stormware.cz/schema/version_2/list.xsd' AS lst
                  ,'http://www.stormware.cz/schema/version_2/list_stock.xsd' AS lStk 
                  ,'http://www.stormware.cz/schema/version_2/list_addBook.xsd' AS lAdb
                  ,'http://www.stormware.cz/schema/version_2/list_centre.xsd' AS lCen
                  ,'http://www.stormware.cz/schema/version_2/list_activity.xsd' AS lAcv
                  ,'http://www.stormware.cz/schema/version_2/accountingunit.xsd' AS acu
                  ,'http://www.stormware.cz/schema/version_2/invoice.xsd' AS inv
                  ,'http://www.stormware.cz/schema/version_2/voucher.xsd' AS vch
                  ,'http://www.stormware.cz/schema/version_2/intDoc.xsd' AS int
                  ,'http://www.stormware.cz/schema/version_2/stock.xsd' AS stk
                  ,'http://www.stormware.cz/schema/version_2/order.xsd' AS ord
                  ,'http://www.stormware.cz/schema/version_2/offer.xsd' AS ofr
                  ,'http://www.stormware.cz/schema/version_2/enquiry.xsd' AS enq
                  ,'http://www.stormware.cz/schema/version_2/vydejka.xsd' AS vyd
                  ,'http://www.stormware.cz/schema/version_2/prijemka.xsd' AS pri
                  ,'http://www.stormware.cz/schema/version_2/balance.xsd' AS bal
                  ,'http://www.stormware.cz/schema/version_2/prevodka.xsd' AS pre
                  ,'http://www.stormware.cz/schema/version_2/vyroba.xsd' AS vyr
                  ,'http://www.stormware.cz/schema/version_2/prodejka.xsd' AS pro
                  ,'http://www.stormware.cz/schema/version_2/contract.xsd' AS con
                  ,'http://www.stormware.cz/schema/version_2/addressbook.xsd' AS adb
                  ,'http://www.stormware.cz/schema/version_2/parameter.xsd' AS prm
                  ,'http://www.stormware.cz/schema/version_2/list_contract.xsd' AS lCon 
                  ,'http://www.stormware.cz/schema/version_2/category.xsd' AS ctg
                  ,'http://www.stormware.cz/schema/version_2/intParam.xsd' AS ipm
                  ,'http://www.stormware.cz/schema/version_2/storage.xsd' AS str
                  ,'http://www.stormware.cz/schema/version_2/individualPrice.xsd' AS idp 
                  ,'http://www.stormware.cz/schema/version_2/supplier.xsd' AS sup
                  ,'http://www.stormware.cz/schema/version_2/print.xsd' AS prn
                  ,'http://www.stormware.cz/schema/version_2/sendEET.xsd' AS sEET 
                  ,'http://www.stormware.cz/schema/version_2/accountancy.xsd' AS act
                  ,'http://www.stormware.cz/schema/version_2/bank.xsd' AS bnk
                  ,'http://www.stormware.cz/schema/version_2/store.xsd' AS sto
                  ,'http://www.stormware.cz/schema/version_2/groupStocks.xsd' AS grs 
                  ,'http://www.stormware.cz/schema/version_2/actionPrice.xsd' AS acp
                  ,'http://www.stormware.cz/schema/version_2/cashRegister.xsd' AS csh
                  ,'http://www.stormware.cz/schema/version_2/bankAccount.xsd' AS bka
                  ,'http://www.stormware.cz/schema/version_2/inventoryLists.xsd' AS ilt
                  ,'http://www.stormware.cz/schema/version_2/numericalSeries.xsd' AS nms
                  ,'http://www.stormware.cz/schema/version_2/payment.xsd' AS pay
                  ,'http://www.stormware.cz/schema/version_2/mKasa.xsd' AS mKasa
                  ,'http://www.stormware.cz/schema/version_2/GDPR.xsd' AS gdp
                  ,'http://www.stormware.cz/schema/version_2/establishment.xsd' AS est 
                  ,'http://www.stormware.cz/schema/version_2/centre.xsd' AS cen
                  ,'http://www.stormware.cz/schema/version_2/activity.xsd' AS acv
                  ,'http://www.stormware.cz/schema/version_2/filter.xsd' AS ftr)

- И использует их в следующих SELECT

SELECT @xml.value('(/rsp:responsePack/@id)[1]','nvarchar(10)') AS ResponsePack_id
       --Header data
      ,@xml.value('(/rsp:responsePack/rsp:responsePackItem/lst:listIntDoc/lst:intDoc/int:intDocHeader/int:id/text())[1]','int') AS ListIntDocHeader_id
      ,@xml.value('(/rsp:responsePack/rsp:responsePackItem/lst:listIntDoc/lst:intDoc/int:intDocHeader/int:myIdentity/typ:address/typ:company)[1]','nvarchar(max)') AS MyAddress_Company
      --data from within each intDocDetail
      ,A.itm.value('(int:text/text())[1]','nvarchar(100)') AS IntDocDetail_Text
      ,A.itm.value('(int:homeCurrency/typ:unitPrice/text())[1]','bigint') AS IntDocDetail_HomeCurrency_UnitPrice
FROM @xml.nodes('/rsp:responsePack/rsp:responsePackItem/lst:listIntDoc/lst:intDoc/int:intDocDetail/int:intDocItem') A(itm);

Я выбрал только несколько значений из типичных мест.Надеюсь, вы сможете узнать все остальное ...

знать о

  • чувствительность к регистру
  • и набрать .value()
...