title: Name cannot begin with the ' ' character, hexadecimal value 0x20 in c# using xml String
body: <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Xml;
  using System.Net;
  using System.IO;
  namespace SOAPServices
  {
      class Program
      {
          static void Main(string[] args)
          {
              CallWebService();
          }
  
  
  public static void CallWebService()
      {
          var _url = "http://exampleurl.svc";
          var _action = "http://examplemethod";
  
          XmlDocument soapEnvelopeXml = CreateSoapEnvelope();
          HttpWebRequest webRequest = CreateWebRequest(_url, _action);
          InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);
  
          // begin async call to web request.
          IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
  
          // suspend this thread until call is complete. You might want to
          // do something usefull here like update your UI.
          asyncResult.AsyncWaitHandle.WaitOne();
  
          // get the response from the completed web request.
          string soapResult;
          using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
          {
              using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
              {
                  soapResult = rd.ReadToEnd();
              }
              Console.Write(soapResult);
          }
      }
  
      private static HttpWebRequest CreateWebRequest(string url, string action)
      {
          HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
          webRequest.Headers.Add("SOAPAction", action);
          webRequest.ContentType = "text/xml;charset=\"utf-8\"";
          webRequest.Accept = "text/xml";
          webRequest.Method = "POST";
          return webRequest;
      }
  
      private static XmlDocument CreateSoapEnvelope()
      {
          XmlDocument soapEnvelopeDocument = new XmlDocument();
          soapEnvelopeDocument.LoadXml(@"&lt;?xml version=""1.0"" encoding=""UTF - 8""?&gt;
  &lt; soapenv:Envelope xmlns:soapenv = ""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ass = ""http://assetrecovery.assurant.com/"" xmlns: ass1 = ""http://schemas.datacontract.org/2004/07/AssetRecovery_Service.Entities"" xmlns: tem = ""http://tempuri.org/"" &gt;
     &lt; soapenv:Header &gt;
        &lt; ass:AuthenticationHeader &gt;
           &lt; !--Optional:--&gt;
           &lt; ass:Password &gt; Testing &lt;/ ass:Password &gt;
           &lt; !--Optional:--&gt;
           &lt; ass:UserName &gt; Testing &lt;/ ass:UserName &gt;
           &lt; !--Optional:--&gt;
           &lt; ass:VersionNumber &gt; 3 &lt;/ ass:VersionNumber &gt;
        &lt;/ ass:AuthenticationHeader &gt;
     &lt;/ soapenv:Header &gt;
     &lt; soapenv:Body &gt;
        &lt; tem:Set_SubmitClaim &gt;
           &lt; !--Optional:--&gt;
           &lt; tem:request &gt;
              &lt; ass1:AccountID &gt; 987605589 &lt;/ ass1:AccountID &gt;
              &lt; ass1:City &gt; WAYNE &lt;/ ass1:City &gt;
              &lt; ass1:ClaimantContactNumber &gt; 9329496466 &lt;/ ass1:ClaimantContactNumber &gt;
              &lt; ass1:ClaimantFirstName &gt; BILL &lt;/ ass1:ClaimantFirstName &gt;
              &lt; ass1:ClaimantLastName &gt; SMITH &lt;/ ass1:ClaimantLastName &gt;
              &lt; ass1:DateOfLoss &gt; 02 / 20 / 2018 &lt;/ ass1:DateOfLoss &gt;
              &lt; !--Optional:--&gt;
              &lt; ass1:EmailAddress &gt; test@test.com &lt;/ ass1:EmailAddress &gt;
              &lt; ass1:InsuredFirstName &gt; BILL &lt;/ ass1:InsuredFirstName &gt;
              &lt; ass1:InsuredLastName &gt; SMITH &lt;/ ass1:InsuredLastName &gt;
              &lt; ass1:LossDescription &gt; DROPPED IN THE MALL TEST &lt;/ ass1:LossDescription &gt;
              &lt; ass1:LossType &gt; PHYSICAL_DAMAGE &lt;/ ass1:LossType &gt;
              &lt; ass1:Manufacturer &gt; APPLE &lt;/ ass1:Manufacturer &gt;
              &lt; ass1:Model &gt; IPHONE 6 PLUS 16GB SPACE GRAY TMO &lt;/ ass1:Model &gt;
              &lt; !--Optional:--&gt;
              &lt; ass1:PhoneProblem &gt; CRACKET SCREEN / DISPLAY &lt;/ ass1:PhoneProblem &gt;
              &lt; ass1:Program &gt; JUMP &lt;/ ass1:Program &gt;
              &lt; ass1:RepID &gt; 7578 &lt;/ ass1:RepID &gt;
              &lt; ass1:SKU &gt; MGAX2LL / A &lt;/ ass1:SKU &gt;
              &lt; ass1:SerialNumber &gt; 105589918105590 &lt;/ ass1:SerialNumber &gt;
              &lt; ass1:State &gt; PA &lt;/ ass1:State &gt;
              &lt; ass1:StreetAddress1 &gt; 676 E SWEDESFORD RD &lt;/ ass1:StreetAddress1 &gt;
              &lt; !--Optional:--&gt;
              &lt; ass1:StreetAddress2 /&gt;
              &lt; ass1:SubscriberID &gt; 8080805589 &lt;/ ass1:SubscriberID &gt;
              &lt; ass1:Zip &gt; 19087 &lt;/ ass1:Zip &gt;
           &lt;/ tem:request &gt;
        &lt;/ tem:Set_SubmitClaim &gt;
     &lt;/ soapenv:Body &gt;
  &lt;/ soapenv:Envelope &gt; ");
          return soapEnvelopeDocument;
          }
  
      private static void InsertSoapEnvelopeIntoWebRequest(XmlDocument soapEnvelopeXml, HttpWebRequest webRequest)
      {
          using (Stream stream = webRequest.GetRequestStream())
          {
              soapEnvelopeXml.Save(stream);
          }
      }
  }
  }
  </code></pre>
  
  <p>By executing the above code I am getting the xml Error like Name cannot begin with the ' ' character, hexadecimal value 0x20. The xml string might causing the issue and I am not able to trace where the exact error is.I found some answers in google but found no luck
  Please can anyone help me on this I am new to C#</p>