package com.softgraf.vendas.model.xml;

import java.io.File;
import java.util.Arrays;
import java.util.List;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

public class TesteLeitorXml extends Application {

	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		
		FileChooser chooser = new FileChooser();
		FileChooser.ExtensionFilter filtro = new FileChooser.ExtensionFilter("Arquivos XML", "*.xml");
		chooser.getExtensionFilters().add(filtro);
		File arquivo = chooser.showOpenDialog(null);
		
		if (arquivo != null) {
			String arquivoXml = arquivo.toString();
			
			// Lista de tags do arquivo xml que serão processadas
			List<String> listaTags = Arrays.asList("id", "nome", "rua", "cidade", "estado");
			
			LeitorXml xml = new LeitorXml();
			List<List<String>> lista = xml.processar(arquivoXml, listaTags);
			
			for (List<String> cliente : lista) {
				System.out.println();
				for (String valor : cliente) {
					System.out.println(valor);
				}
			}
			
			Platform.exit();
		}
		
	}

}
