package edu.unl.consystlab.sudokuSolver;
import java.io.*;
import java.util.Hashtable;
import java.util.List;
import java.util.LinkedList;

import javax.xml.parsers.*;

import org.w3c.dom.*;
import org.xml.sax.SAXException;

public class testXMLFormat {
	
	public testXMLFormat()
	{
	}

	public String testXMLFormat(String fileName)
	{
		DocumentBuilderFactory factoryBuilder;
		DocumentBuilder builder;
		Document doc;
		Element docElement;
		NodeList currentNodeList;
		String format = null;
		try
		{
			factoryBuilder  = DocumentBuilderFactory.newInstance( );
			builder = factoryBuilder.newDocumentBuilder();
			doc = builder.parse( fileName );
			docElement = doc.getDocumentElement();

			//Read the presentation properties like name
			currentNodeList = docElement.getElementsByTagName("presentation");			
			format = currentNodeList.item(0).getAttributes().getNamedItem("format").getNodeValue();
			System.out.println(format);
		}
		catch (IOException e)
		{
			System.out.println("IO ERROR10");
			System.out.println(e);			
		}
		catch (ParserConfigurationException e)
		{
			System.out.println("IO ERROR11");
			System.out.println(e);			
		}
		catch (SAXException e)
		{
			System.out.println("IO ERROR12");
			System.out.println(e);			
		}
		
		return format;		
	}	
}
