Using system; using system. net; using system. collections. generic; using system. io; using system. XML; namespace ciceng {public class cicengjson {public object xmltojson () {var xml = file. readalltext (@ "D: \ cnblogs. XML "); // This XML is the backup file xmldocument Doc = new xmldocument (); Doc. loadxml (XML); // get the content var channelxml = Doc under the RSS node. selectsinglenode ("RSS "). innerxml; // further refine the XML format. The content is only the content Doc under the RSS node. loadxml (channelxml); // serialize the XML to JSON and remove the root node var JSON = jsonconvert. serializexmlnode (Doc, newtonsoft. JSON. formatting. none, true);} public object jsontoobject (Object JSON) {var channel = jsonconvert. deserializeobject <channel> (JSON); return channel;} public class channel {Public String title {Get; set;} Public String link {Get; set ;} public String description {Get; set;} Public String language {Get; set;} Public String lastbuilddate {Get; set;} Public String pubdate {Get; set ;} public String TTL {Get; set;} public list <channel_item> item {Get; Set ;}} public class channel_item {Public String title {Get; set ;} public String link {Get; set;} Public String author {Get; set;} Public String pubdate {Get; set;} Public String guid {Get; set ;} public item_description description {Get; set;} public class item_description {// The Node serialized in JSON format using the variable name by default. Because the node content does not comply with the variable definition specification, the specified [jsonproperty ("# CDATA-section")] Public String content {Get; Set ;}}/* // contains is displayed, using Newton. replace javascriptserializer with JSONCode Public override void executeresult (controllercontext context) {If (this. Data! = NULL) {isodatetimeconverter timeformat = new isodatetimeconverter (); timeformat. datetimeformat = "yyyy-mm-dd hh: mm: SS"; response. write (jsonconvert. serializeobject (this. data, newtonsoft. JSON. formatting. indented, timeformat, x);) ;}re-define a controller, name it jsoncontroller, and set it as an abstract class. Then rewrite the method: protected internal virtual jsonresult JSON (Object Data, string contenttype, encoding contentencoding, describehavior) {return New jsonresult {DATA = data, contenttype = contenttype, contentencoding = contentencoding, jsonrequestbehavior = behavior};} changed jsonresult to the class that inherits jsonresult and overwrites the executeresult method! // Configure. */