title: XML from SQL Server
body: <p>tried below, but until and unless I made AcknowledgeShipmentInbound node empty (deleting
  releaseID=&quot;9.2&quot; xmlns=&quot;http://schema.infor.com/InforOAGIS/2&quot;
  xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;) select query is not fetching the value.</p>
  <pre class="lang-sql prettyprint-override"><code>    Declare @xmlData xml
      set @xmlData = '&lt;?xml version=&quot;1.0&quot;?&gt;
      &lt;AcknowledgeShipmentInbound releaseID=&quot;9.2&quot; xmlns=&quot;http://schema.infor.com/InforOAGIS/2&quot; 
      xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt; 
      &lt;ApplicationArea&gt;
          &lt;Sender&gt;
              &lt;LogicalID&gt;lid://ln01/2100&lt;/LogicalID&gt;
              &lt;ComponentID&gt;erp&lt;/ComponentID&gt;
              &lt;ConfirmationCode&gt;OnError&lt;/ConfirmationCode&gt;
          &lt;/Sender&gt;
          &lt;CreationDateTime&gt;2021-09-02T09:22:03Z&lt;/CreationDateTime&gt;
          &lt;BODID&gt;1630574520554:123461:0&lt;/BODID&gt;
       &lt;/ApplicationArea&gt;
       &lt;DataArea&gt;
          &lt;Acknowledge&gt;
              &lt;TenantID&gt;KP_TRN&lt;/TenantID&gt;
              &lt;AccountingEntityID&gt;2100&lt;/AccountingEntityID&gt;
              &lt;LocationID&gt;S_2100&lt;/LocationID&gt;
              &lt;OriginalApplicationArea xmlns=&quot;&quot;&gt;
                  &lt;Sender&gt;
                      &lt;LogicalID&gt;oracle_erp_ihub_v2&lt;/LogicalID&gt;
                      &lt;ComponentID&gt;External&lt;/ComponentID&gt;
                      &lt;ConfirmationCode&gt;OnError&lt;/ConfirmationCode&gt;
                  &lt;/Sender&gt;
                  &lt;CreationDateTime&gt;2021-09-02T09:22:00.554Z&lt;/CreationDateTime&gt;
                  &lt;BODID&gt;ihub_v2:1630574520554:123461:0&lt;/BODID&gt;
              &lt;/OriginalApplicationArea&gt;
              &lt;ResponseCriteria&gt;
                  &lt;ResponseExpression actionCode=&quot;Rejected&quot;/&gt;
                  &lt;ChangeStatus&gt;
                      &lt;ReasonCode&gt;tlbcts0074&lt;/ReasonCode&gt;
                      &lt;Reason languageID=&quot;en-US&quot;&gt;Request validation; SHIPMENTS WITH REQUEST ID 
         2021090205 the value is too long.&lt;/Reason&gt;
                  &lt;/ChangeStatus&gt;
              &lt;/ResponseCriteria&gt;
          &lt;/Acknowledge&gt;
          &lt;ShipmentInbound&gt;
              &lt;ShipmentInboundHeader&gt;
                  &lt;DocumentID&gt;
                      &lt;ID&gt;Shipments with request id 28880902052200&lt;/ID&gt;
                  &lt;/DocumentID&gt;
              &lt;/ShipmentInboundHeader&gt;
              &lt;ShipmentInboundLine&gt;NONE&lt;/ShipmentInboundLine&gt;
          &lt;/ShipmentInbound&gt;
      &lt;/DataArea&gt;
      &lt;/AcknowledgeShipmentInbound&gt;'
  
     Declare @DocumentType nvarchar(100)
     DECLARE @DocumentId NVARCHAR(128);
  
     Select T.c.value('(DocumentID/ID/text())[1]', 'VARCHAR(128)')
     FROM @xmlData.nodes('*:AcknowledgeShipmentInbound/*:DataArea/*:ShipmentInbound/*:ShipmentInboundHeader') T(c)
  
  
              select T.c.query('./DocumentID/ID').value('.','nvarchar(128)')   as DocumentID
              from @xmlData.nodes('/AcknowledgeShipmentInbound/DataArea/ShipmentInbound/ShipmentInboundHeader') T(c)
  </code></pre>