Click here to Skip to main content
15,889,694 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
:confused::confused::confused:

I'm a C# developer. I've never used XML before.
I've written a script that automates some creation of documents.
I've been asked to do something in the following line:


"Convert your output data to XML format sothat program X can understand and use your data."

My Question:
What steps do you recommend I take?
Posted
Comments
OriginalGriff 11-Nov-10 9:52am    
I'd start by looking at what program X can understand and accept...
R. Erasmus 12-Nov-10 2:13am    
Thanks for the suggestion, I will have a look at it.

1 solution

i have to add some sample code to converting data to xml format and saved into xml file.. refer it and apply in ur page


String path=Server.MapPath("~\\xml\\");
Stream xmlFile = new FileStream(path+ "Contacts.xml", FileMode.Append);
XmlTextWriter reader = new XmlTextWriter(xmlFile, Encoding.UTF8);

reader.Formatting = Formatting.Indented;
reader.WriteStartDocument();
reader.WriteStartElement("Contacts");
reader.WriteStartElement("Contact");
string stname = txtName.Text.Trim();
string stadd = textareaAddress.Text.Trim();
string stcompany = txtCompany.Text.Trim();
string stphone = txtPhone.Text.Trim();
string stemail = txtEmail.Text.Trim();
string stcomments = txtComments.Text.Trim();
reader.WriteElementString("Name",stname);
reader.WriteElementString("Address", stadd);
reader.WriteElementString("Company", stcompany);
reader.WriteElementString("Phone Number",stphone);
reader.WriteElementString("Email Address",stemail);
reader.WriteElementString("Comments", stcomments);
reader.WriteElementString("Contact Date", DateTime.Now.ToString());

reader.WriteEndElement();
reader.WriteEndElement();
reader.WriteEndDocument();
reader.Close();


if u agreed above the answer press accept answer or put vote for this answer..

regards
Sasi
 
Share this answer
 
v3
Comments
R. Erasmus 12-Nov-10 2:10am    
Thanks, will have a look at it. It looks like something I can work with.
ramuksasi 12-Nov-10 2:25am    
best of luck Rudolf..

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