انا عم حاول اطبق الكود بس لسا عم يطلعلي اخطاء ممكن حد يساعدني بتطبيقه




using System;


using System.IO;


using System.Net;


using System.Windows.Forms;


using System.Xml;


//using Newtonsoft.Json;





namespace JSON2XML


{


public partial class Form1 : Form


{


public Form1()


{


InitializeComponent();


}





private void Form1_Load(object sender, EventArgs e1)


{


/* because the origional JSON string has multiple root's this needs to be added */


string json = "{BFBC2_GlobalStats:";


json += DownlodUrl("http://api.bfbcs.com/api/xbox360?globalstats");


json += "}";





XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(json);


textBox1.Text = GetXmlString(doc);


}





private string DownlodUrl(string url)


{


string result = null;


try


{
WebClient client = new WebClient();


result = client.DownloadString(url);


}


catch (Exception ex)


{


// handle error


result = ex.Message;


}


return result;


}





private string GetXmlString(XmlDocument xmlDoc)


{


StringWriter sw = new StringWriter();


XmlTextWriter xw = new XmlTextWriter(sw);


xw.Formatting = System.Xml.Formatting.Indented;


xmlDoc.WriteTo(xw);


return sw.ToString();


}
}


}