Convert Json To Xml
I know this has been asked many many times. But honestly with so many tries, the solutions are not working for me. As I am working in ASP.Net 1.1, so can not handle this .net level
Solution 1:
Hi try something like this. This works great for my applications, but haven't used it outside them so hope it helps.
publicstringParseJsonToXml(string sJsonObject)
    {
        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(string));
        MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(sXMLJson));
        string sXMLDeSerialized = (string)ser.ReadObject(ms);
        ms.Close();
        return sXMLDeSerialized;
    }
I parse it to string in order so that i can convert the xml into a dataset and vice versa.
public DataSet ParseXmlToDataSet(string sXml)
    {      
        DataSetds=newDataSet();
        StringReadersr=newStringReader(sXml);
        ds.ReadXml(sr);
        return ds;
    }
to get the XML of the dataset use
//ds is typeof(DataSet)
ds.GetXml();
Note: This is how my data processed looks like
<DATA><TLOGIN><USER>thabo.pali@za.pwc.com</USER><PASSWORD>"Monday@01</PASSWORD></TLOGIN></DATA>Regards George
Post a Comment for "Convert Json To Xml"