Click here to Skip to main content
12,633,764 members (27,695 online)
Click here to Skip to main content

Stats

94K views
1.2K downloads
35 bookmarked
Posted

Converter for Microsoft Project 2002 XML file to TODOLIST XML file

, 23 Jan 2006 Ms-PL
Converter for Microsoft Project 2002 XML file to TODOLIST XML file.
TODOListConverter.exe
TODOListConverter
App.ico
bin
Release
TODOListConverter.csproj.user
ViewHTML.asp_files
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)

Share

About the Author

Maharishi Bhatia
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.

You may also be interested in...

Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161208.2 | Last Updated 23 Jan 2006
Article Copyright 2005 by Maharishi Bhatia
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid