Paul Cornell blogs about the view controls we create for you in VSTO 2.0 when you have XML structure in your Word document.
A couple of additional notes I would add:
UpdateXML: One of the cool additional things we added to XMLNode is a new method called “UpdateXML“. This method provides you with an easy way to set the XML of any node and all children nodes in one fell swoop. Following Paul’s example, I could write this code:
Where myVar is either a string, an XMLDocument, or an XMLElement.
UpdateXMLFrom: We also provide another method on XMLNode called “UpdateXMLFrom“ that takes a file name. So I could write this code:
Invalid XML Structure: In Word, you can apply invalid XML structure to a document. For example, you could have this situation where you have two “book“ roots in one document.
In this situation, we can’t really distinguish between the multiple roots well enough to provide you with reliable view control support. So we punt. You need to apply valid XML structure for us to create view controls with you.
Element Centric Schemas: Word’s XML support is very element centric. If you have a schema with a bunch of attributes, these types of schemas don’t work as well in Word (even though they work fine in Excel)–so try to use a schema that is light on attributes or you’ll really get hung up.
Mixed Content: Also, in most cases you’ll want to use a schema that supports mixed content because chances are you’ll want to have formatting or headers in your document that aren’t really part of your schema. mixed=“true“ is your friend in Word when defining any complexType in your schema.