Featured Post

Smart Product designer

Image
download and purchase link: https://alkanyx.com/item/49/Smart+Product+designer

Live preview : http://smartproductdesigner.000webhostapp.com/

Smart Product Designer is a  tool to create your own product and get directly from your website. It is well documented, very easy to customize and use. It is build using most advance technologies including javascript, jQuery and html5.
Features Choose different product from collectionAdd custom texts to product.Change text colorChange the size and font of the TextLet the user drag, move or remove elementsAdd images to product selected from art gallery or browse it from systemDesign both frontside and back-sideShows preview while designingDownload designVery easy to customize and useHere is the purchase link : https://alkanyx.com/item/49/Smart+Product+designer

Convert content of XML file to JSON string in C#.Net

Convert content of XML file to JSON string in C#.Net
The below function will convert the content of XML file to JSON string:


private string convertXMLToJSON()
        {
            string xmlLogPath = "<<Path to the xml file>>";

            // Load the XML file
            var xDocument = System.Xml.Linq.XDocument.Load(xmlLogPath);

            // Read the XML file content and write it to string
            string xml = xDocument.ToString();

            // Load the XML string
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            // Convert the XML string to JSON string
            string jsonText = JsonConvert.SerializeXmlNode(doc);

            //Release the memory
            doc = null;
            xmlLogPath = null;
            xml = null;
            xDocument = null;
    
            //Return the JSON string
            return jsonText;

        }
IMPORTANT NOTE:

Releasing object memory is very important. Even if your object went out of scope, it is not removed from the garbage collection. It happens because the variable still has some value in it. So Garbage collector think that the variable is in use and it doesn't remove it from the memory.

Setting it to NULL, tells the garbage collector that the object is no longer in use and can be removed from the garbage collection.

Comments