Iterationen
Im nachstehenden Code wird gezeigt, wie man durch offene Dokumente iteriert.
01 // Iterate through open documents and set view mode to 'Text'.
02 for (Document doc:xmlSpy.getDocuments())
03 if ( doc.getCurrentViewMode() != SPYViewModes.spyViewText)
04 doc.switchViewMode(SPYViewModes.spyViewText);
05
06 // An alternative iteration mode is index-based
07 // COM indices are typically zero-based
08 Documents documents = xmlSpy.getDocuments();
09 for (int i = 1; i <= documents.getCount();
10 i++)
11 {
12 Document doc = documents.getItem(i);
13 ...
14 }