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><F irstName>XML</FirstName><Last Name>Guru</LastName><Membe rName>guru@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 = "guru@xml.c om";
StringWriter sw = new StringWriter();
XmlSerializer xs = new XmlSerializer(o bs.GetType());
xs.Serialize(sw , obs);
String xout = sw.ToString();
public class OutBS
{
public String FirstName;
public String LastName;
public String MemberName;
}
--------------------------------------------------------------------------------
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><F irstName>XML</FirstName><Last Name>Guru</LastName><Membe rName>guru@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 = "guru@xml.c om";
StringWriter sw = new StringWriter();
XmlSerializer xs = new XmlSerializer(o bs.GetType());
xs.Serialize(sw , obs);
String xout = sw.ToString();
public class OutBS
{
public String FirstName;
public String LastName;
public String MemberName;
}
--------------------------------------------------------------------------------
Comment