Import java. util .*;
Import org. JDOM .*;
Import org. JDOM. Input. saxbuilder;
Public class sample1 {
Public static void main (string [] ARGs) throws exception {
Saxbuilder sb = new saxbuilder ();
Document Doc = sb. Build (sample1.class. getclassloader (). getresourceasstream ("Beans. xml"); // construct a Document Object
Element root = Doc. getrootelement (); // get the root element HD
List list = root. getchildren ("Bean"); // obtain all elements named Disk
For (INT I = 0; I <list. Size (); I ++ ){
Element element = (element) list. Get (I );
String id = element. getattributevalue ("ID ");
String clazz = element. getattributevalue ("class ");
System. Out. println (ID );
System. Out. println (clazz );
/*
String capacity = element. getchildtext ("capacity"); // obtain the content of the disk sub-element capacity
String directories = element. getchildtext ("directories ");
String files = element. getchildtext ("Files ");
System. Out. println ("disk information :");
System. Out. println ("partition drive letter:" + name );
System. Out. println ("partition capacity:" + capacity );
System. Out. println ("number of directories:" + Directories );
System. Out. println ("number of files:" + files );
System. Out. println ("-----------------------------------");
*/
}
}
}