public class Object
{
public string data1 { get; set; }
public string data2 { get; set; }
public string ToXmlString()
{
var serializer1 = new XmlSerializer(this.GetType());
var ns = new XmlSerializerNamespaces();
ns.Add("", "");
var sw1 = new StringWriter();
var xmlWriter = XmlWriter.Create(sw1, new XmlWriterSettings() { OmitXmlDeclaration = true});
serializer1.Serialize(xmlWriter, this, ns);
string xml = sw1.ToString();
return xml;
}
}
ATTRIBUTE OmitXmlDeclaration = true will remove attribute of document xml
Wednesday, May 31, 2017
How to convert Object to XML without attribute
Subscribe to:
Post Comments (Atom)
No comments:
Write comments