Created
September 30, 2018 02:21
-
-
Save tuxcuiabano/d54fb47188f3fa7c123b88a413e2a236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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