Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
Wenn du nur einen einzigen Wert aus der XML Datei lesen willst, dann ist ein regulärer Ausdruck die einfachste Lösung.
Aus der ganzen Datei einen einzigen langen String machen und dann per RegEx suchen.
Meine XML Datei ist ca 2500 Zeilen lang. Wie soll ich das dann machen ?
static String findAttribute(String fileName, String tag, String attribute) {
try {
String xml = new String(Files.readAllBytes(new File(fileName).toPath()), "utf8");
String regEx = "<\\s*" + tag + "[^<>]*?\\s" + attribute + "\\s*=\\s*(\".*?\"|\'.*?\')";
Matcher m = Pattern.compile(regEx).matcher(xml);
if(m.find()) {
String atr = m.group(1);
return atr.substring(1, atr.length()-1);
} else return null;
} catch(Exception e) {
return null;
}
}
atts.getValue("attribut") != null