260
|
|
static AppFile loadAppFile(File file) throws ParserConfigurationException,
|
261
|
|
SAXException, IOException {
|
262
|
|
AppFile appFile = AppFile.newFile();
|
263
|
|
|
264
|
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
265
|
|
factory.setNamespaceAware(true);
|
266
|
|
DocumentBuilder DocumentBuilder = factory.newDocumentBuilder();
|
267
|
|
Document xmlDoc = DocumentBuilder.parse(file);
|
268
|
|
|
269
|
|
Element element = xmlDoc.getDocumentElement();
|
270
|
|
|
271
|
|
NodeListIterable nodeListIterable = appFile.new NodeListIterable(
|
272
|
|
element.getElementsByTagName("BookList"));
|
273
|
|
for (Node node : nodeListIterable) {
|
274
|
|
for (Node subNode : appFile.new NodeListIterable(((Element) node)
|
275
|
|
.getElementsByTagName("Book"))) {
|
276
|
|
appFile.addBook(Book.getBookFromXML((Element) subNode));
|
277
|
|
}
|
278
|
|
}
|
279
|
|
|
280
|
|
appFile.setModified(false);
|
281
|
|
appFile.setPath(file.getAbsolutePath());
|
282
|
|
|
283
|
|
return appFile;
|
284
|
|
}
|