As a developer who frequently creates custom XML files, and the associated schemas, one thing that's always bothered me is the lack of IntelliSense when writing my custom XML. It's available for some XML files, such as your standard web.config. Why can't I get the same treatment?
I had always assumed that there was a hyper-complex process, likely involving registry hacks and general misery.
As it turns out, my assumption made an... well, let's just say I was wrong. Perhaps this is old news, but if so I didn't get the memo. Nor the one about the cover sheets for TPS reports, actually, but that's another story entirely.
Regardless, the process is actually quite simple. Start with a basic schema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ElementOne" minOccurs="0" />
<xs:element name="ElementTwo" minOccurs="0" />
<xs:element name="ElementThree" minOccurs="1" />
When writing a new XML file that conforms to this schema, there is no IntelliSense:
But with a couple of clicks, IntelliSense is actually available:
To make this amazing magic happen for yourself (in Visual Studio 2008), start by creating your schema, presumably as part of your project. Then, open your XML file, and select the XML menu:
Now select the Schemas menu item. That will pop up the Schemas dialog:
Find the schema you just created (in our example, SomeSchema.xsd), and then instruct Studio to use this schema:
Then viola! You now get IntelliSense on your custom XML!