Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
*I've been working on a CSVexporter but keep getting stuck at certain points*

**Any ideas how I could solve this problem ? it seems is has an error in here piece of code ( see link )*
[enter image description here][1]


[1]: https://i.stack.imgur.com/L4kZE.png

What I have tried:

I've tried reconnecting to the database but didn't work out well
Posted
Updated 19-Apr-17 22:01pm

1 solution

XmlTextWriter writer = new XmlTextWriter("visitors.xml", Encoding.UTF8);

writer.WriteStartDocument();
writer.WriteStartElement("visitors");

using (CsvReader reader = new CsvReader("visitors.csv"))
{
	reader.ReadHeaders();

	while (reader.ReadRecord())
	{
		writer.WriteStartElement("visitor");

		writer.WriteElementString("visitor_id", reader["visitor_id"]);
		writer.WriteElementString("first_name", reader["first_name"]);
		writer.WriteElementString("last_name", reader["last_name"]);

		writer.WriteEndElement();
	}

	reader.Close();
}

writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();<pre><pre lang="c#">
 
Share this answer
 
v2

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