Skip to content

Instantly share code, notes, and snippets.

@tuxcuiabano
Created September 30, 2018 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxcuiabano/d54fb47188f3fa7c123b88a413e2a236 to your computer and use it in GitHub Desktop.
Save tuxcuiabano/d54fb47188f3fa7c123b88a413e2a236 to your computer and use it in GitHub Desktop.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package parsersax;
/**
*
* @author tuxcuiabano
* Retirado do Livro Texto "Tecnologia de Dados para
* Internet - MACIEL, C, 2018"
*/
import org.xml.sax.*;
import org.xml.sax.helpers.XMLReaderFactory;
import java.io.*;
public class ParserSAX {
public static void main(String args[]){
if (args.length == 0) {
System.err.println("Informar o arquivo XML: /" +
"java ParserXML <arquivo.xml>");
System.exit(1);
}
try {
XMLReader parser = XMLReaderFactory.createXMLReader();
parser.parse(args[0]);
System.out.println(args[0]+ "é um documento XML bem formado.");
}
catch (SAXException e) {
System.out.println(args[0] + " não é um documento XML bem formado.");
}
catch (IOException e) {
System.out.println("Problema para carregar o arquivo " +
args[0]); }
} // Fim da função main
} // Fim da classe XML_SAX_wellformed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment