package defaultpackage;
/*
 * Created on 26 nov. 2003
 * 
 * To change the template for this generated file go to Window - Preferences -
 * Java - Code Generation - Code and Comments
 */

import java.io.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import javax.xml.parsers.*;

public class parser {

	public PrintWriter out = null;

	//Rem changer Package par ModelElement
	public void parse(String _fichier)
		throws SAXException, ParserConfigurationException, IOException {

		// Charger le document
		FileInputStream _xml_input_file = new FileInputStream(_fichier);
		
		parse(_xml_input_file);
	}

	public void parse(InputStream _xml_input_file) throws SAXException, ParserConfigurationException, IOException
	{

		
		//instancier le contrcuteur de parseurs
		DocumentBuilderFactory _factory = DocumentBuilderFactory.newInstance();

		//ignorer les commentaires dans les fichiers XML parsè
		_factory.setIgnoringComments(true);
		
		// créé un parseur
		DocumentBuilder _builder = _factory.newDocumentBuilder();

		// Charger le document
		Document doc = _builder.parse(_xml_input_file);

		// Parser le document
		Element bib = doc.getDocumentElement();
		NodeList filsDeRacine = bib.getChildNodes();
		
		
		BufferedReader keyboard=new BufferedReader(new InputStreamReader(System.in));
		String typevoulu=""; //init
		try{
			typevoulu=keyboard.readLine();//Recup du texte
		}catch(IOException e){
			System.out.println("error");
		}
		String champs=null;
		Element a_afficher = null;
		for(int i=0 ; i<filsDeRacine.getLength();i++)
		{
			Node node = filsDeRacine.item(i);			
			if(node.getNodeType()== Node.ELEMENT_NODE)
			{
				a_afficher = (Element)bib.getElementsByTagName(typevoulu).item(0);
			}
		}
		if(a_afficher==null)
		{System.out.println("Type introuvable\n");}
		else
		{
			champs = a_afficher.getTextContent();
			System.out.println(champs);
		}
			
	
	}
}