import java.io.*;
import java.util.*;


import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import org.jdom.Document;
import org.jdom.Element;
import org.xml.sax.InputSource;

public class ReadXmlWithJDom {
	public static void main(String args[]){
		new ReadXmlWithJDom();
	}
	public ReadXmlWithJDom(){
		SAXBuilder builder = new SAXBuilder();
		InputSource ipt = new InputSource("C:\\mmm.xml");
		Document doc=null;
		try {
			doc = builder.build(ipt);
		} catch (Exception e) {			
			e.printStackTrace();
		}
		
		// Get the root element
		Element root = doc.getRootElement();		
		
		// Get file info element list			
		Element eleFileInfo = (Element)root.getChildren("FileInfo").get(0);//FileInfo´Â µ¿ÀÏ»óÀ§  Element°¡ 1°³¸¸ Á¸ÀçÇÏ¹Ç·Î get(0)À» »ç¿ë
		List lstFileInfo = eleFileInfo.getChildren();	
		Iterator irFileInfo = lstFileInfo.iterator();		
		//###################################################################
		Hashtable<String, String> hFileInfo = new Hashtable<String, String>();
		//###################################################################
		while(irFileInfo.hasNext()){
			Element tmpElement = (Element) irFileInfo.next();			
			hFileInfo.put(tmpElement.getName(), tmpElement.getValue());
			//System.out.println(tmpElement.getName()+tmpElement.getValue());
		}
		
		
		// Get extraction option element list			
		Element exOption = (Element)root.getChildren("ExtractionOption").get(0);
		Element autoSelect = (Element)exOption.getChildren("AutoSelect").get(0);
		//###################################################################
		String autoSelectValue = autoSelect.getAttribute("checked").getValue();
		String timeFrom;
		String timeEnd;
		String fileSizeFrom;
		String fileSizeEnd;
		String perValue;
		//###################################################################		
		List lstAutoSelect = autoSelect.getChildren();	
		Iterator irAutoSelect = lstAutoSelect.iterator();
		while(irAutoSelect.hasNext()){
			Element tmpElement = (Element) irAutoSelect.next();			
			String tmpEl = tmpElement.getName();
			if(tmpEl.equals("Time")){
				timeFrom = tmpElement.getAttribute("from").getValue();
				timeEnd = tmpElement.getAttribute("end").getValue();
			}else if(tmpEl.equals("FileSize")){
				fileSizeFrom = tmpElement.getAttribute("from").getValue();
				fileSizeEnd = tmpElement.getAttribute("end").getValue();				
			}else if(tmpEl.equals("GOP")){
				perValue = tmpElement.getAttribute("per").getValue();
			}
		}
		
		// Get frame size element list			
		Element frameSize = (Element)root.getChildren("FrameSize").get(0);
		List lstFrameSize = frameSize.getChildren();
		Iterator irFrameSize = lstFrameSize.iterator();
		//###################################################################
		String []frameSizeValue = new String[lstFrameSize.size()];
		//###################################################################
		int irCnt=0;
		while(irFrameSize.hasNext()){
			Element tmpElement = (Element) irFrameSize.next();			
			frameSizeValue[irCnt++]=tmpElement.getAttribute("size").getValue();			
		}
		
		// Get frame size element list			
		Element _elextractFileName = (Element)root.getChildren("ExtractFileName").get(0);
		//###################################################################
		String extractFileName = _elextractFileName.getValue();
		//###################################################################
		
		// Get SelectFileName element list			
		Element _selectFileName = (Element)root.getChildren("SelectFileName").get(0);
		//###################################################################
		String selectFileName = _selectFileName.getValue();
		//###################################################################
		
				
		// Get AutoSelect element list			
		Element _autoSelect = (Element)root.getChildren("AutoSelect").get(0);
		//###################################################################
		String autoType = _autoSelect.getAttribute("type").getValue();
		String autoValue = _autoSelect.getAttribute("value").getValue();
		//###################################################################
			
		
				 
		XMLOutputter outp = new XMLOutputter(Format.getPrettyFormat());
				 
		try{			
    		outp.output(doc, System.out);    		
    	}
    	catch (IOException e) {
    		System.out.println(e);
		}
		
	}		
}

