/*
* Created by vincent.tollu@gmail.com
* IDE: SharpDevelop
* Distributed under the GPL
*/
static void Main(string[] args)
{
try
{
StreamReader inputlist = File.OpenText(@"C:\input.txt");
MemoryStream streamy = new MemoryStream();
XmlTextWriter xmlwriter = new XmlTextWriter(streamy, Encoding.UTF8);
xmlwriter.Formatting = System.Xml.Formatting.Indented;
xmlwriter.Indentation = 2;
xmlwriter.WriteStartDocument();
xmlwriter.WriteStartElement("KDONoel");
string input = null;
while ((input = inputlist.ReadLine()) != null)
{
xmlwriter.WriteStartElement("Friend");
string[] split = input.Split(' ');
xmlwriter.WriteElementString("name", split[0]);
xmlwriter.WriteElementString("adress", split[1]);
xmlwriter.WriteElementString("lover", "");
xmlwriter.WriteEndElement();
}
inputlist.Close();
xmlwriter.WriteEndElement();
xmlwriter.WriteEndDocument();
xmlwriter.Flush();
//Now open the lover tag
ASCIIEncoding enc = new ASCIIEncoding();
string stXml = enc.GetString(streamy.ToArray());
stXml = stXml.Replace("", "");
StreamWriter stout = new StreamWriter(@"C:\Documents and Settings\vtollu\Desktop\out.xml", false, Encoding.UTF8);
stout.WriteLine(stXml);
stout.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadKey();
}
}