Hallo.
Hatte vorher auch keine Ahnung. Doch dank der folgenden Beitraege konnte ich es einfach loesen:
Musste nur ein wenig rumexperementieren:
Der Beitrag von Olivier Boisse
I have an example XML as follows: <message> <metadata> <msg_id>1</msg_id> <client_type>type1</client_type> </metadata> <individual> ...
stackoverflow.com
und
This is an example of how to visit all elements in a DOM Document. A DOM is a standard tree structure, where each node contains one of the components from
examples.javacodegeeks.com
Notwendige imports:
import javax.xml.xpath.*;
import org.xml.sax.SAXException;
import java.io.FileReader;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
So verwendet man es:
File file = new File(offlineUrlXbrlUrl);
// E:/doppelt/test.txt
XPath xPath = XPathFactory.newInstance().newXPath();
String expression = "//*[not(*)]";
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document document = builder.parse(file);
document.getDocumentElement().normalize();
NodeList nodeList = (NodeList) xPath.compile(expression).evaluate(document, XPathConstants.NODESET);
for(int i = 0 ; i < nodeList.getLength(); i++) {
if(nodeList.item(i).getNodeName().contains("us-gaap") && nodeList.item(i).getTextContent().length() < 15) {
Habe dann hier abgesucht was us-gaap enthaelt.
Gruß
Axel Pfennig, Duesseldorf