Click here to Skip to main content
15,891,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my xml format
i want to write this in json format
please help me
private static byte[] GenerateXMLEmployee(string strFirstName,
string strLastName, int intEmpCode, string strDesignation)
{

XmlTextWriter xmlWriter = new XmlTextWriter(@"C:\Employee.xml", Encoding.UTF8);
XmlTextWriter xmlWriter = new XmlTextWriter(mStream, Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("Employee");
xmlWriter.WriteStartElement("FirstName");
xmlWriter.WriteString(strFirstName);
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("LastName");
xmlWriter.WriteString(strLastName);
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("EmpCode");
xmlWriter.WriteValue(intEmpCode);
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("Designation");
xmlWriter.WriteString(strDesignation);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
xmlWriter.Close();
return mStream.ToArray();
}
Posted

1 solution

This[^] will answer all your questions.

[Please accept/up-vote answers or solutions that work for you to encourage participation]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900