当前位置 : 主页 > 网络编程 > net编程 >

C# JSON字符串转带头(声明)XML字符串

来源:互联网 收集:自由互联 发布时间:2023-09-14
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


C# JSON字符串转带头(声明)XML字符串_html


参考地址:https://www.yzktw.com.cn/post/1160585.html

https://devbox.cn/p/106706727

http://md5.cn/tools/json2xml/

上一篇:Redis启动器项目RunRedisServer在github开源了
下一篇:没有了
网友评论