I think this name space is giving a problem when the user exports to a SAP module, how could I remove it. How would I do to leave only the XMLTYPE, without the name space.
<RVE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><RVE>
I tested it with excel xml and there is no error and the difference I noticed is that it didn’t have this xmlns: xsi and xmlns: xsd
My Model class:
[XmlType("RVE")]
public class ApontamentoExportarViewModel
{
[XmlElement(ElementName = "ITEM")]
public int Item { get; set; }
[XmlElement(ElementName = "EQUIPAMENTO")]
public int Equipament{ get; set; }
}
My formatter class:
public class XmlActionResult<T> : ActionResult
{
public XmlActionResult(List<T> data)
{
Data = data;
}
public List<T> Data { get; private set; }
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "text/xml";
// TODO: Use your preferred xml serializer
// to serialize the model to the response stream :
// context.HttpContext.Response.OutputStream
ApontamentoExportarViewModel apontamentoExportarViewModel = new ApontamentoExportarViewModel();
int fileName = 0;
if (Data is List<ApontamentoExportarViewModel>)
{
var record = (Data as List<ApontamentoExportarViewModel>).FirstOrDefault();
if (record != null)
fileName = record.Equipamento;
}
var cd = new System.Net.Mime.ContentDisposition
{
// for example foo.bak
FileName = string.Format("MA_" + fileName + "_{0:yyyyMMdd_HHmm}.xml", DateTime.Now),
// always prompt the user for downloading, set to true if you want
// the browser to try to show the file inline
Inline = false,
};
var root = new XmlRootAttribute("meadinkent");
XmlSerializer x = new XmlSerializer(Data.GetType(), root);
context.HttpContext.Response.AppendHeader("Content-Disposition", cd.ToString());
x.Serialize(context.HttpContext.Response.OutputStream, Data);
}
}
}