public static String getXMLItem(String fileString, String rootTag, String leseTag) {
try {
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse(
new File(fileString));
doc.getDocumentElement().normalize();
NodeList nodeLst = doc
.getElementsByTagName(rootTag);
Node fstNode = nodeLst.item(0);
Element fstElmnt = (Element) fstNode;
NodeList lstNmElmntLst = fstElmnt.getElementsByTagName(leseTag);
Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
NodeList lstNm = lstNmElmnt.getChildNodes();
return ((Node) lstNm.item(0)).getNodeValue();
} catch (Exception e) {
JOptionPane
.showMessageDialog(
frame,
"Fehler beim Lesen\n\n"
+ "Bitte überprüfen Sie die Existenz der Datei:\n"
+ fileString
, "Fehler!!",
JOptionPane.WARNING_MESSAGE);
System.exit(-1);
return null;
}
}