title: Striping All values form XML string using TSQL (SQL SERVER 2008)
body: <p>I'm looking into a problem where i need to be comparing a given XML to what user inputs without the values, so for example if this is the user input:</p>
  
  <pre><code>    &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
          &lt;soapenv:Body&gt;
              &lt;genRetrieve xmlns:v1="http://xxxxxxxxxxxxxxxxxxxxx"&gt;
                  &lt;checkRetrieve&gt;
                      &lt;party&gt;
                          &lt;user&gt;
                              &lt;first&gt;BLA&lt;/first&gt;
                              &lt;last&gt;last&lt;/last&gt;
                          &lt;/user&gt;
                          &lt;media&gt;none&lt;/media&gt;
                      &lt;/party&gt;
                  &lt;/checkRetrieve&gt;
              &lt;/genRetrieve&gt;
          &lt;/soapenv:Body&gt;
      &lt;/soapenv:Envelope&gt; 
  </code></pre>
  
  <p>I need to produce the following and insert it into another table:</p>
  
  <pre><code>  &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
          &lt;soapenv:Body&gt;
              &lt;genRetrieve xmlns:v1="http://xxxxxxxxxxxxxxxxxxxxx"&gt;
                  &lt;checkRetrieve&gt;
                      &lt;party&gt;
                          &lt;user&gt;
                              &lt;first&gt;&lt;/first&gt;
                              &lt;last&gt;&lt;/last&gt;
                          &lt;/user&gt;
                          &lt;media&gt;&lt;/media&gt;
                      &lt;/party&gt;
                  &lt;/checkRetrieve&gt;
              &lt;/genRetrieve&gt;
          &lt;/soapenv:Body&gt;
      &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p><strong>without the formatting (spaces, line feeds ...etc).</strong></p>
  
  <p>Can anyone please give an example on how this could be archived? I intially used the blow metoh:</p>
  
  <pre><code>    DECLARE @hdoc     int
      DECLARE @doc      varchar(2000)
  
      SET @doc = 'my xml'
  
      EXEC sp_xml_preparedocument @hdoc OUTPUT, @doc
  
      SELECT * FROM OPENXML( @hdoc, '/*',2)
  
      EXEC sp_xml_removedocument @hdoc
      GO
  </code></pre>
  
  <p>but it seemes tricky to build the final XML string using the output of the table from above command, if you could show me the standard/most efficient way (given there will xml strings with many elements in them) it would be much appreciated.</p>