title: Dot Net XML node Un-Escape double quotes
body: <p>I have a WinForms application in Dot Net framework 4.5 which generates output from SQL Server data into an XML file which is sent to a Third-party. I am getting the outputs correctly for 99% of the cases but have an issue whenever a description field contains special characters like Single Quote(') or Double Quote (&quot;) or Ampersand(&amp;) in the description text. These characters get correctly escaped but the Third-party wants this field Description text as Un-escaped and I have spent a lot of time trying to figure out how to do it.</p>
  <p>Here is my code:</p>
  <pre><code> Dim xmlLineItems As New XmlDocument
   Dim elements As IEnumerable(Of XElement)
   Dim LineItemCnt As Integer
  
  Using conn As New SqlConnection(My.Settings.myconstr)
      conn.Open()
      Dim SQL1 As String = String.Empty
      SQL1 = &quot;SELECT SrNo as 'Number',PartsDesc as 'Description' ,QtyApproved as 'Quantity', UOMCode as 'MeasureUOM', (SELECT DeptName as '@DepartmentType',CatDesc as '@Name',ModelDesc as '@ModelNumber',LineItem.DwnNo as '@DrawingNumber'  FROM MyViewMaster  where MasterID = LineItem.MasterID FOR XML path ('Section'), Type) FROM MyViewDetails LineItem  WHERE LineItem.MasterID = 4567809 AND StatusID &lt;&gt; 3 ORDER BY SrNo FOR XML AUTO, type&quot;
  
      Dim cmd1 As New SqlXmlCommand(My.Settings.myconstr)
      cmd1.RootTag = &quot;Data&quot;
      cmd1.CommandText = SQL1
      Dim xreader As System.Xml.XmlReader = cmd1.ExecuteXmlReader
      xmlLineItems.Load(xreader)
      conn.Close()
  End Using
  Dim lists As XmlNodeList = xmlLineItems.SelectNodes(&quot;.//LineItem&quot;)
  elements = lists.Cast(Of XmlNode)().[Select](Function(node) XDocument.Parse(node.OuterXml).Root)
  
  </code></pre>
  <p>This generates a list of items and a sample of the LineItem output is as below:</p>
  <pre><code>
  &lt;LineItem Number=&quot;1&quot;
    . . .
  &lt;/LineItem&gt;
  &lt;LineItem Number=&quot;19&quot; Description=&quot;DETTOL WASH 5 LTR&quot; Quantity=&quot;1&quot; MeasureUOM=&quot;PCE&quot;&gt;
          &lt;Section DepartmentType=&quot;HouseKeeping&quot; Name=&quot;Consumables&quot; ModelNumber=&quot;&quot; DrawingNumber=&quot;&quot; /&gt;
  &lt;/LineItem&gt;
  &lt;LineItem Number=&quot;20&quot; Description=&quot;HAND SHOWER CHROMED, 1/2&amp;quot;&quot; Quantity=&quot;3&quot; MeasureUOM=&quot;PCE&quot;&gt;
          &lt;Section DepartmentType=&quot;HouseKeeping&quot; Name=&quot;Accessories&quot; ModelNumber=&quot;&quot; DrawingNumber=&quot;&quot; /&gt;
  &lt;/LineItem&gt;
  &lt;LineItem Number=&quot;120&quot;
   . . . . . 
  &lt;/LineItem&gt;
  
  </code></pre>
  <p>I need to have the Description as &quot;HAND SHOWER CHROMED, 1/2&quot;&quot;  (Un-EScaped) only for this field.</p>
  <p>How do I go about achieving this?</p>
  <p>Some additional information: This field is marked as CDATA in the DTD by the 3rd Party to whom we need to send this XML file.</p>