private string ConverXml(string memberId, int code, string msg) { var resp = new { authenticate = new { member_id = memberId, status_code = code, message = msg } }; var jsonstr = JsonConvert.SerializeObject(resp); XmlDocument doc = JsonConv
private string ConverXml(string memberId, int code, string msg)
{
var resp = new { authenticate = new { member_id = memberId, status_code = code, message = msg } };
var jsonstr = JsonConvert.SerializeObject(resp);
XmlDocument doc = JsonConvert.DeserializeXmlNode(jsonstr);
XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", "utf-8", "yes");
XmlElement root = doc.DocumentElement;
doc.InsertBefore(xmldecl, root);
return doc.InnerXml;
}
返回XML
参考地址:https://www.yzktw.com.cn/post/1160585.html
https://devbox.cn/p/106706727
http://md5.cn/tools/json2xml/