I need to return IHttpActionResult, Ok(xml).
Variable xml is a string data type. The problem is next...
When the program returns string xml, it adds \\r\\n for a NewLine, string escape characters ().
I want to return a clean xml string.
For example, this string i want to return:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<ProxyGlave>
<Glava ID="530064">
<DatumIsporuke>1900-01-01T00:00:00</DatumIsporuke>
</Glava>
<Glava ID="530065">
<DatumIsporuke>1900-01-01T00:00:00</DatumIsporuke>
</Glava>
</ProxyGlave>
But my program returns this:
"
<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n
<ProxyGlave>\r\n
<Glava ID=\"530064\">\r\n
<DatumIsporuke>1900-01-01T00:00:00</DatumIsporuke>\r\n
</Glava>\r\n
<Glava ID=\"530065\">\r\n
<DatumIsporuke>1900-01-01T00:00:00</DatumIsporuke>\r\n
</Glava>\r\n
</ProxyGlave>"
Screenshot from Postman tool:
Code which generates string XML:
XDocument xdoc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("ProxyGlave",
from gl in glave
select
new XElement("Glava", new XAttribute("ID", gl.DokumentiGlaId),
new XElement("DatumIsporuke", gl.datum_isporuke)))
);
return Ok(xdoc.ToString());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.