0

I have an old web API that build directly XML as XElement. I want to switch to ASP.NET core 6 web api but I want to return the same XML as before. So I don't need serialisation I want to return directly my XElement What must I do ?

Jean

dbc
  • 104,963
  • 20
  • 228
  • 340
jeanf
  • 31
  • 3
  • Have you tried returning the `XElement`? What problem do you have? If the problem is that it is getting serialized as JSON then you may need to attach an XML serializer as shown in [Why won't my ASP.Net Core Web API Controller return XML?](https://stackoverflow.com/q/38316358) and configure to return XML as shown in [How to make ASP.NET Core return XML result?](https://stackoverflow.com/q/59190580).. Since you are returning `XElement` I believe either XmlSerializer or DataContractSerializer should work. – dbc Apr 27 '22 at 17:38
  • Can this help you? https://stackoverflow.com/questions/8373552/serialize-an-object-to-xelement-and-deserialize-it-in-memory – Tiny Wang Apr 28 '22 at 06:23

0 Answers0