Important The information set out in this topic regarding Microsoft Word is presented exclusively for the benefit and use of individuals and organizations who are located outside the United States and its territories or who are using, or developing programs that run on, Microsoft Word products that were licensed by Microsoft before January 2010, when Microsoft removed an implementation of particular functionality related to custom XML from Microsoft Word. This information regarding Microsoft Word may not be read or used by individuals or organizations in the United States or its territories who are using, or developing programs that run on, Microsoft Word products that were licensed by Microsoft after January 10, 2010; those products will not behave the same as products licensed before that date or purchased and licensed for use outside the United States.
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.
Microsoft Office version
For more information, see Features Available by Application and Project Type.
The XMLNodes control is a collection of mapped XML node objects that exposes events. The XMLNodes control is created only when a repeating schema element is mapped onto a Microsoft Office Word document. If the repeating element contains child elements, each of the child elements is also created as an XMLNodes control.
After Visual Studio Tools for Office creates the collection of XML nodes, you can program against the control directly without having to traverse the Word object model. The XMLNodes control can be deleted only by removing the element mapping from the document.
If you access a child element of the XMLNodes control through the Item property, it returns a XMLNode object rather than a Microsoft.Office.Tools.Word.XMLNode control. For more information, see Programmatic Limitations of Host Items and Host Controls.
Binding Data to the Control
Any formatting that can be applied to text within the document can be applied to an XMLNodes control.
The events available for the XMLNodes control are:
You can capture an event when the user moves his or her cursor inside the context of a particular XMLNodes control. For example, you might have an XMLNodes control named Customer that has a child XMLNodes control named Company, and Company has two child XMLNodes controls named CompanyName and CompanyRegion as follows:
<Customer> <Company> <CompanyName> <CompanyRegion>
If you want to show a control on the actions pane whenever the cursor is moved into the Company node, it should not matter whether the cursor is placed in CompanyName or CompanyRegion because they are both within the context of Company. In this case, you can write your code in the ContextEnter event of Company.
Occurs when the cursor is placed inside one of the nodes of the XMLNodes collection.
Occurs when the cursor is placed inside one of the nodes or descendant nodes of the XMLNodes collection, from an area outside of the context of the node. In other words, it is raised only when the context changes, and can be raised for multiple nested XMLNodes controls.
For example, when you move the cursor from outside of Customer into CompanyName, the ContextEnter events for Customer, Company, and CompanyName are raised. If you then move the cursor from CompanyName to CompanyRegion, the ContextEnter event only for CompanyRegion is raised, because the context is the same for both Company and Customer. You can have multiple Company nodes in your document. If you move the cursor from the CompanyName node of one Company to the CompanyName node of another Company, the context is the same, so only the Select event is raised.