I want to create a XML file in csharp like the below format pls help me with the code
<MasterEntries>
<fruit>Apple</fruit>
<animal>Fox</animal>
<color>Violet</color>
</MasterEntries>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, if you have .NET 3.5 available to you, I’d recommend you use LINQ to XML. For example:
That’s about as simple as it gets 🙂
EDIT: Okay, in .NET 2.0 it’s a bit more cumbersome. Something like this:
There may well be simpler ways of doing this, but I don’t know them…
Once you’ve got an
XElement/XDocument/XmlDocument, you can callSaveto save it to a file.