Advanced Customization > Info*Engine User’s Guide > Server Access Kit > About the Server Access Kit > SAK Example Method
  
SAK Example Method
The following example method traverses a Group object to display all of its Element objects and their attributes:
private void displayObjects (Group objects) {
 //
 // xmlDisplay is a boolean instance variable that defines
 // whether the Group should be rendered as XML or as plain
 // text.
 //

    if ( xmlDisplay ) {
        PrintWriter pw = new PrintWriter (System.out);
        objects.toXML (pw, true, true);
    }
    else {
        int n = objects.getElementCount ();
        for ( int i = 0; i < n; ++i ) {

     //
     // Print one empty line between Elements
     //
         System.out.println ("");
         Element object = objects.getElementAt (i);
         Enumeration atts = object.getAtts ();
         while ( atts.hasMoreElements () ) {

     //
     // Render each attribute as "name: value"
     // If an attribute is multivalued, indent each
     // value such that they are vertically aligned.
     //

             Att att = (Att)atts.nextElement ();
             String name = att.getName ();
             System.out.print (name + ": ");
             Enumeration values = att.getValues ();

             int v = 0;

             while ( values.hasMoreElements () ) {

               Object value = values.nextElement ();

                  if ( v++ > 0 ) {

                      System.out.print (" ");

           for ( int s = 0; s < name.length (); ++s )
                         System.out.print (" ");
                    }

             System.out.println (value);
             }
           }
       System.out.println ("");
    }
 }