Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "XML":
- text.append("Processing file type XML: "+files[i].getCanonicalPath() + "n" );
- ReadXml read_xml = new ReadXml();
- read_xml.read(files[i].getCanonicalPath(), text);
- break;
- public class ReadXml {
- ProgramDocument programDocument = new ProgramDocument();
- public void read(String FILE, javax.swing.JTextArea text ) {
- try {
- JAXBContext context = JAXBContext.newInstance(ProgramDocument.class);
- Unmarshaller u = context.createUnmarshaller();
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(FILE);
- Object o = u.unmarshal( doc );
- doc.getDocumentElement().normalize();
- text.append("Account : " +doc.getElementsByTagName("Account").item(0));
- }
- catch(Exception e) {
- text.append("XML file not parsed correctly.n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement