Hi there XML Gurus ;)
I am trying to use XML Serialization to create a xml from a class, this is the output which I get when I create the XML and put in a string variale.
"<?xml version=\"1.0\" encoding=\"utf-16\"?><OutBS><FirstName>XML</FirstName><LastName>Guru</LastName><MemberName>gu**@xml.com</MemberName></OutBS>"
My question is why am I getting the encoding as UTF-16, I want a UTF-8 encoding, how can this be achieve by getting the output in the xout string variable.
Help is really appreciated.
thanks,
shailendra batham
// Create the xout xml here.
OutBS obs = new OutBS();
obs.FirstName = "XML";
obs.LastName = "Guru";
obs.MemberName = "gu**@xml.com";
StringWriter sw = new StringWriter();
XmlSerializer xs = new XmlSerializer(obs.GetType());
xs.Serialize(sw, obs);
String xout = sw.ToString();
public class OutBS
{
public String FirstName;
public String LastName;
public String MemberName;
}
--------------------------------------------------------------------------------