title: text/xmldecl not at the beginning of input
body: <p>I am trying to insert xml file in database but i am getting this error text/xmldecl not at the beginning of input.</p>
  
  <p>Here is the query:</p>
  
  <pre><code>INSERT [EMR].[tblTemplateForm]
   (FormXML)
   VALUES ( CAST('&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;EMR&gt;
    &lt;CustomTextBox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;Text&gt;0.0&lt;/Text&gt;
      &lt;Type&gt;TextBox&lt;/Type&gt;
      &lt;Width&gt;300&lt;/Width&gt;
      &lt;id&gt;txt1&lt;/id&gt;
      &lt;Label&gt;POG(LMP)&lt;/Label&gt;
      &lt;LabelWidth&gt;200&lt;/LabelWidth&gt;
      &lt;labelFontStyle&gt;normal&lt;/labelFontStyle&gt;
      &lt;labelFontWeight&gt;normal&lt;/labelFontWeight&gt;
      &lt;labelFontColor&gt;Black&lt;/labelFontColor&gt;
      &lt;CaptionOrientation&gt;Horizontal&lt;/CaptionOrientation&gt;
      &lt;NewControl&gt;false&lt;/NewControl&gt;
      &lt;NumericText&gt;0&lt;/NumericText&gt;
      &lt;TextMode&gt;Singleline&lt;/TextMode&gt;
      &lt;rows&gt;0&lt;/rows&gt;
      &lt;columns&gt;0&lt;/columns&gt;
    &lt;/CustomTextBox&gt;&lt;?xml version="1.0"?&gt;
    &lt;CustomNumericTextBox xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;Type&gt;NumericTxtBox&lt;/Type&gt;
      &lt;Width&gt;500&lt;/Width&gt;
      &lt;id&gt;numTxt1&lt;/id&gt;
      &lt;Label&gt;numTxt1&lt;/Label&gt;
      &lt;LabelWidth&gt;200&lt;/LabelWidth&gt;
      &lt;labelFontStyle&gt;normal&lt;/labelFontStyle&gt;
      &lt;labelFontWeight&gt;normal&lt;/labelFontWeight&gt;
      &lt;labelFontColor&gt;Black&lt;/labelFontColor&gt;
      &lt;CaptionOrientation&gt;Horizontal&lt;/CaptionOrientation&gt;
      &lt;NewControl&gt;false&lt;/NewControl&gt;
      &lt;NumericText&gt;3&lt;/NumericText&gt;
    &lt;/CustomNumericTextBox&gt;&lt;?xml version="1.0"?&gt;
    &lt;AllControlsCount xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;Width&gt;0&lt;/Width&gt;
      &lt;id&gt;ControlsID&lt;/id&gt;
      &lt;LabelWidth&gt;0&lt;/LabelWidth&gt;
      &lt;NewControl&gt;false&lt;/NewControl&gt;
      &lt;NumericText&gt;0&lt;/NumericText&gt;
      &lt;lblCount&gt;0&lt;/lblCount&gt;
      &lt;txtCount&gt;12&lt;/txtCount&gt;
      &lt;numTxtCount&gt;1&lt;/numTxtCount&gt;
      &lt;ddlCount&gt;0&lt;/ddlCount&gt;
      &lt;rbCount&gt;0&lt;/rbCount&gt;
      &lt;cbCount&gt;0&lt;/cbCount&gt;
    &lt;/AllControlsCount&gt;
  &lt;/EMR&gt;' as XML))
   GO
  </code></pre>
  
  <p><strong>Error message:</strong></p>
  
  <pre><code>Msg 9438, Level 16, State 1, Line 1
  XML parsing: line 19, character 24, text/xmldecl not at the beginning of input
  </code></pre>
  
  <p><strong>Table structure:</strong></p>
  
  <pre><code>TABLE [EMR].[tblTemplateForm](
      [FormID] [int] IDENTITY(1,1) NOT NULL,
      [FormName] [varchar](100) NULL,
      [FormDesc] [varchar](255) NULL,
      [FormXML] [xml] NULL,
      [Published] [bit] NULL,
      [FormType] [int] NULL,
      [CreatedID] [int] NULL,
      [CreatedDate] [datetime] NULL,
      [ModifiedID] [int] NULL,
      [ModifiedDate] [datetime] NULL,
  </code></pre>