示例#1
0
        public string XmlToJson(string xml)
        {
            string removeParenthese  = xml.Replace("(", String.Empty);
            string removeParenthese1 = removeParenthese.Replace(")", String.Empty);
            object yourOjbect        = new JavaScriptSerializer().DeserializeObject(removeParenthese1);
            var    test = string.Concat("<? xml version = '1.0'>", yourOjbect.ToString());

            try
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(yourOjbect.ToString());
                return(ConvertToJson.XmlToJSON(document));
            }
            catch (Exception ex)
            {
                return("Bad Xml format");
            }
        }