Click here to Skip to main content
15,895,084 members
Articles / Programming Languages / XML

Converter for Microsoft Project 2002 XML file to TODOLIST XML file

Rate me:
Please Sign up or sign in to vote.
4.42/5 (12 votes)
23 Jan 2006Ms-PL3 min read 116.6K   1.3K   35  
Converter for Microsoft Project 2002 XML file to TODOLIST XML file.
using System;
using System.IO;
namespace TODOListConverter
{
	class MainClass
	{
		[STAThread]
		static int Main(string[] args)
		{
			string msg = @"**********************************************
TODOLIST Generator for Microsoft Project 2002
Created By : Maharishi Bhatia
Created Date : 13 May 2005
Version : 1.0
Description : Converter for Microsoft Project 2002 xml file to TODOLIST xml file.
**********************************************";
			Console.WriteLine(msg);
			string file = "";
		#if DEBUG
			file = @"D:\ToDoList\Converter\TODOListConverter\MSProjectPro2003XMLOutput.xml";
		#else 
			if(args.Length == 0){
				msg = @"Usage : TODOListConverter.exe <Full Path of the File to be Converted>";
				goto error;
			}
			file = args[0];
		#endif
			FileInfo f = new FileInfo(file);
			if(f.Exists){
				StreamReader s = new StreamReader(f.FullName);
				string xml = s.ReadToEnd();
				xml = System.Text.RegularExpressions.Regex.Replace(xml, "(s*)xmlns=\"http://schemas.microsoft.com/project\"(s*)",string.Empty);
				XmlTransformer transform = new XmlTransformer();
				xml = transform.Transform(xml);
				if(xml != null && xml.Length > 0){
					System.Text.StringBuilder str = new System.Text.StringBuilder(xml);
					str.Remove(0,106);
					xml = str.ToString();

					StreamWriter write = new StreamWriter(f.Directory+"\\"+"TODO_"+f.Name+".tdl",false,System.Text.Encoding.ASCII);
					write.WriteLine(xml,write.NewLine);
					write.Flush();
					write.Close();
				}else{
					msg = "Error : No data after transformation.";
					goto error;
				}
			}else{
				msg = "Error : Not a valid File";
				goto error;
			}
		#if DEBUG
			Console.ReadLine();
			return 0;
		#else
			Console.WriteLine("TODOList File {0} successfully created at {1} directory.","TODO_"+f.Name,f.Directory);
			return 0;
		#endif
			error:{
				Console.WriteLine(msg);
				return -1;
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Program Manager Capgemini
United States United States
I have been working in software industry for the past 11 years, though i am trained to be a pharmacist. Enjoy working on complex and new technologies. Also cleared my SCJP and MCP certification examinations.

Comments and Discussions