title: Parsing XML with namespaces in SQL Server
body: <p>I am having a hard time trying to parse an XML that has some namespaces defined:</p>
  
  <pre><code>&lt;TravelItineraryReadRS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="2.2.0"&gt;    
  &lt;TravelItinerary xmlns="http://webservices.sabre.com/sabreXML/2011/10"&gt;
  &lt;CustomerInfo&gt;          
  &lt;PersonName WithInfant="false" NameNumber="01.01" RPH="1"&gt;              
  &lt;GivenName&gt;JEFF S&lt;/GivenName&gt;"
  </code></pre>
  
  <p>The XMl is stored in an XML type column named response, and I want to get the GivenName value, for which I use the below query:</p>
  
  <pre><code>;WITH XMLNAMESPACES (DEFAULT 'http://webservices.sabre.com/sabreXML/2011/10')
  select 
  response.value('(/TravelItineraryReadRS/TravelItinerary/CustomerInfo/PersonName[1]/GivenName)[1]', 'nvarchar(50)') AS Name
  from dbo.RezMonitorXMLdataTest where locator = 'GUBXRV'
  </code></pre>
  
  <p>but instead of getting JEFF S as a result I get NULL. I think this might be related to the namespaces used. Does anyone know how could I get the GivenName value?</p>
  
  <p>Thanks in advance,</p>
  
  <p>Guzmán</p>