c# - XML Serializer customization -
i need serialize .net object xml. want retrieve following output:
<?xml version="1.0" encoding="utf-8"?> <resendrealisation> <datefrom>2012-12-15 03:00:00</datefrom> <dateto>2012-12-15 23:59:59</dateto> <folderpath></folderpath> </resendrealisation> i use xmlserializer such objects:
public class resendrealisation { public resendrealisation() { folderpath = string.empty; } public resendrealisation(datetime from, datetime to) :this() { datefrom = from.tostring("yyyy-mm-dd hh:mm:ss"); dateto = to.tostring("yyyy-mm-dd hh:mm:ss"); } public string datefrom { get; set; } public string dateto { get; set; } public string folderpath { get; set; } } and
var serializer = new xmlserializer(typeof(resendrealisation)); serializer.serialize(stream, request); and output looks like:
<?xml version="1.0"?> <resendrealisation xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <datefrom>2013-08-07 12:38:00</datefrom> <dateto>2013-08-08 12:38:00</dateto> <folderpath /> </resendrealisation> so, can see there missed encoding attribute, , there redundant xmlns:xsi , xmlns:xsd attributes. how can remove them , add missed attributes?
Comments
Post a Comment