I need to remove the xsd and xsi namespaces from my MVC api response but I can't make it work. (The reason I need to remove them is because we're sending it to a third party map provider, and it doesn't work if you include them.) I've read a bunch of other questions, for example this which is asking the exact same thing but the answer doesn't work, and I've tried to implement a custom formatter as per this answer, but no luck there either unfortunately. Does anyone know what I need to do? Should I just give up and use a handler instead?
Model:
[XmlType(TypeName = "MapPoints")]
[XmlRoot(DataType = "", Namespace = "http://tempuri.org/XMLFile1.xsd")]
public class MapPointList
{
public MapPointList()
{
Points = new List<MapPoint>();
}
[XmlElement("Point")]
public List<MapPoint> Points { get; set; }
}
Controller:
public class MyController : ApiController
{
public MyController()
{
var xmlFormatter = GlobalConfiguration.Configuration.Formatters.XmlFormatter;
xmlFormatter.SetSerializer<MapPointList>(new XmlSerializer(typeof (MapPointList)));
xmlFormatter.SetSerializer<MapPoint>(new XmlSerializer(typeof (MapPoint)));
}
[HttpGet]
public MapPointList SearchMap()
{
var items = new MapPointList();
// get the items
return items;
}
}
My root should look like this:
<MapPoints xmlns="http://tempuri.org/XMLFile1.xsd">
Let me know if I need to add any more information.