Sunday, November 16, 2014

Methord used to create Xml By Passing the Object without root node

 /// <summary>
        /// Methord used to create Xml By Passing the Object without root node
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static XmlDocument ObjectTOXmlTemp(object obj)
        {
            XmlDocument xDoc;
            MemoryStream tempStream = new MemoryStream();
            xDoc = new XmlDocument();
            try
            {
                // Create an XmlSerializer instance using the method below.
                XmlSerializer myXmlSerializer = CreateOverrider(obj.GetType());
                myXmlSerializer.Serialize(tempStream, obj);
                tempStream.Position = 0;
                xDoc.Load(tempStream);
            }
            catch
            {
            }
            finally
            {
                tempStream.Close();
                tempStream.Dispose();
            }
            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 {     ...