XML parsing is too slow!

I wrote a Java application to communicate with a web application using XML. After deployment, I found out that it takes too much time to parse the XML generated by the web application.

For example, it takes about 2 minutes to enter; registration information is included in the URL. The web application does its processing and responds to the Java application whether the login using the returned XML was successful.

I used the standard DOM parsing in java format.

Is there a way to optimize this process so that actions can be faster?

+3
source share
4 answers

XML, 1 . , 20 . , XML

+2

, , DocumentBuilder :

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

factory.setNamespaceAware(false);
factory.setValidating(false);
factory.setFeature("http://xml.org/sax/features/namespaces", false);
factory.setFeature("http://xml.org/sax/features/validation", false);
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

// then take a builder via `factory.newDocumentBuilder()` and parse doc with that builder
+22

parse , . , , . XML ByteArrayOutputStream, , , ( commons-io) . , .

, , - . LDAP- , LDAP , JNDI.

+2

What @Nathan said, plus I suggest doing a random pause while it takes so long. I came across this in the past and found that this is not parsing, which takes time, but the creation and manipulation of the data structure in the analysis. You can see something else, but most likely this is a surprise.

0
source

All Articles