Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/
Try using SAXReader library.
Here is the sample program.
public static DOM4JSettingsNode readSettingsFile(ImportInteraction importInteraction, FileFilter fileFilter) { File file = importInteraction.promptForFile(fileFilter); if (file == null) { return null; } if (!file.exists()) { importInteraction.reportError("File does not exist: " + file.getAbsolutePath()); return null; //we should really sit in a loop until they cancel or give us a valid file. } try { SAXReader reader = new SAXReader(); Document document = reader.read(file); return new DOM4JSettingsNode(document.getRootElement()); } catch (Throwable t) { LOGGER.error("Unable to read file: " + file.getAbsolutePath(), t); importInteraction.reportError("Unable to read file: " + file.getAbsolutePath()); return null; }}
public static DOM4JSettingsNode readSettingsFile(ImportInteraction importInteraction, FileFilter fileFilter) {
File file = importInteraction.promptForFile(fileFilter);
if (file == null) {
return null;
}
if (!file.exists()) {
importInteraction.reportError("File does not exist: " + file.getAbsolutePath());
return null; //we should really sit in a loop until they cancel or give us a valid file.
try {
SAXReader reader = new SAXReader();
Document document = reader.read(file);
return new DOM4JSettingsNode(document.getRootElement());
} catch (Throwable t) {
LOGGER.error("Unable to read file: " + file.getAbsolutePath(), t);
importInteraction.reportError("Unable to read file: " + file.getAbsolutePath());
You should import
import org.dom4j.io.SAXReader;
This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!
1.4k questions
1.6k answers
866 comments
1.9k users