Click here to Skip to main content
13,354,886 members (86,680 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 23 Aug 2004

XML Namespace Shell Extension

, 23 Aug 2004
Rate this:
Please Sign up or sign in to vote.
A shell extension to associate applications with particular XML namespaces.

Sample Image - XmlNamespaceShell.png


This utility allows you to associate a different editor with an XML namespace, while keeping your existing file associations intact.


If you have ever used the Microsoft Office 2003 Save as XML feature in Word or Excel, you will have seen that although the file has a .xml file extension, it still opens with the appropriate Office application. Digging a little deeper, you will see that there is a processing instruction <?mso-application progid="Word.Document"?> in the XML file that the Office shell extension reads, to determine which application to open.

Although this is a cool feature, it is a bit limited because:

  1. It is not extensible.
  2. If it was extensible, you would need to modify your existing XML documents to include a processing instruction.

With these problems in mind, I started looking for some code to:

  1. Intercept the shell invoke on XML documents.
  2. Read the root element of the XML to determine the namespace.
  3. Determine which application to open.
  4. If the namespace has no application associated, default to the original file extension handler.

I found the Creating a shell extension with C# article by Richard Birkby which is almost a perfect fit for the shell extension I needed. I have also used the isolated storage class from Persisting Application data using HashTable and IsolatedStorage by T Manjaly for storing the associations per user.

Using the code

The bulk of the code is best explained by the two excellent articles referenced above.

The application consists of an exe and a DLL. The exe is used to install and uninstall the shell extension (the DLL), and to add and remove namespaces. Once the extension is installed, you can use the menu to add and remove namespaces on the fly without needing to uninstall.

Using the example in the screenshot above, any XML documents that have as the namespace on their root element, will open with Notepad.exe.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Colin Savage
Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralWhat's wrong of Pin
Anonymous24-Aug-04 9:03
sussAnonymous24-Aug-04 9:03 
GeneralRe: What's wrong of Pin
Colin Savage24-Aug-04 9:55
memberColin Savage24-Aug-04 9:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 24 Aug 2004
Article Copyright 2004 by Colin Savage
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid