Sunday, November 16, 2014

Methord used to create Xml By Passing the Object

  /// <summary>
        /// Methord used to create Xml By Passing the Object
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static XmlDocument ObjectTOXml(object obj)
        {
            string xmlStr;
            string startBlock;
            string endBlock;
            startBlock = "{'root':";
            endBlock = "}";
            xmlStr = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
            //Adding A common Parent Node to the json String
            xmlStr = startBlock + xmlStr + endBlock;
            //Converting the json String to Xml
            XmlDocument xDoc = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(xmlStr);

            return xDoc;
        }

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...