title: Create XML string for Web Service
body: <p>I am sending a request to a web service which requires a string containing XML, of which I have been giving an XSD.</p>
  
  <p>I've ran xsd.exe and created a class based on this but am unsure of the best way to create the xml string to send, for example a stream, XMLDocument or some form of serialization.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I found this <a href="https://stackoverflow.com/questions/1429593/how-do-i-control-the-xml-part-of-xml-serialization-with-net">here</a></p>
  
  <pre><code> public static string XmlSerialize(object o)
      {
          using (var stringWriter = new StringWriter())
          {
              var settings = new XmlWriterSettings
              {
                  Encoding = Encoding.GetEncoding(1252),
                  OmitXmlDeclaration = true
              };
              using (var writer = XmlWriter.Create(stringWriter, settings))
              {
                  var xmlSerializer = new XmlSerializer(o.GetType());
                  xmlSerializer.Serialize(writer, o);
              }
              return stringWriter.ToString();
          }
      }
  </code></pre>
  
  <p>which lets me control the  tag attribute.</p>