Altova XMLSpy 2025 Professional Edition

The code snippet below (from the AutomateXMLSpy example; see the file Form1.cs) shows how to iterate through open documents. A condition is then tested within the iteration loop, and the document view is switched between Text View and Authentic View.

 

 

 // Handler for the "Toggle view mode" button

       private void toggleView_Click(object sender, EventArgs e)

       {

           // Make sure there's a running XMLSpy instance, and that it's visible

           StartXMLSpy_Click(null, null);

 

           // Iterate through open documents and toggle current view between text and authentic view.

           foreach (XMLSpyLib.Document doc in XMLSpy.Documents)

               if (doc.CurrentViewMode == XMLSpyLib.SPYViewModes.spyViewText)

                   doc.SwitchViewMode(XMLSpyLib.SPYViewModes.spyViewAuthentic);

               else

                   doc.SwitchViewMode(XMLSpyLib.SPYViewModes.spyViewText);

       }

 

 

The AutomateXMLSpy example example is located in the C# subfolder of the API Examples folder:

 

 

Windows 7, Windows 8, Windows 10, Windows 11

C:\Users\<username>\Documents\
Altova\XMLSpy\2025\Examples

 

You can compile and run the project from within Visual Studio 2012/2013/2015/2017/2019/2022.

 

© 2018-2024 Altova GmbH