I have json string which is deserialized into c# class object, now I am trying serialize it into xml and writing same to the xml file. It does not have any errors or exceptioins but unable to write on xml file. The class has array of objects
Below is my code:
This is class:
public class WorkspaceRootObject
{
public WorkspaceRootObject()
{
}
public string id { get; set; }
public string name { get; set; }
public string description { get; set; }
public string contextId { get; set; }
}
This is serialization:
//deserializing json
wso= JsonConvert.DeserializeObject <List<WorkspaceRootObject>>(finalResponse);
Console.WriteLine("after deserializing...");
FileStream fs = new FileStream("D:\\Rohit_VisualStudio\\ServerManagementFormRest\\bin\\Debug\\WorkSpaceDetails.xml", FileMode.OpenOrCreate);
//serializing into xml
XmlSerializer xs = new XmlSerializer(typeof(List<WorkspaceRootObject>), new System.Type[] {typeof(WorkspaceRootObject)});
TextWriter sw = new StreamWriter(fs);
xs.Serialize(sw, wso);
I have used Newtonsoft json. and after opening xml file it shows Invalid at the top level of the document. Error processing resource 'file:///D:/ProjectLocation/...