Created
January 10, 2024 01:34
-
-
Save robsonkades/ded1a95ef04d50421e3f84c2289133ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | |
DocumentBuilder builder = factory.newDocumentBuilder(); | |
factory.setNamespaceAware(true); | |
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); | |
factory.setFeature("http://xml.org/sax/features/external-general-entities", false); | |
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); | |
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); | |
factory.setFeature("http://xml.org/sax/features/namespaces", true); | |
factory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalDTD", ""); | |
factory.setAttribute("http://javax.xml.XMLConstants/property/accessExternalSchema", ""); | |
XPath xpath = XPathFactory.newInstance().newXPath(); | |
int i = 0; | |
while (i < 9000000) { | |
try (InputStream resourceAsStream = getClass().getResourceAsStream("/file.xml")) { | |
Document doc = builder.parse(resourceAsStream); | |
String expression = "/ArquivosZipados/Arquivo"; | |
NodeList nodeList = (NodeList) xpath.evaluate(expression, doc, XPathConstants.NODESET); | |
for (int is = 0; is < nodeList.getLength(); is++) { | |
Node pai = nodeList.item(is); | |
String expressionChild = "./ConteudoBase64"; | |
NodeList child = (NodeList) xpath.evaluate(expressionChild, pai, XPathConstants.NODESET); | |
for (int f = 0; f < child.getLength(); f++) { | |
System.out.println(i); | |
} | |
} | |
} | |
i++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment