0

I am trying to parse an XML file with 1000 elements using DOM API in Java. It takes 30 seconds to process the XML file.

1 element, for eg store is the root and it has around 15 children like store name, store count, store location, etc...

Is there any other API that can be used to make the whole thing faster?

How about using JAXB (I do not know much about JAXB but I am told by my peers to consider it)?

5
  • have you tried using SAX instead of DOM? Try Apache Digester library. Commented Oct 20, 2011 at 15:56
  • 1
    30 seconds for 1000 elements seems excessive. But the problem is probably in your "processing", not the API. How big is the file? Can you provide some code? Commented Oct 20, 2011 at 15:57
  • What do you want to do with the parsed xml? Commented Oct 20, 2011 at 15:58
  • constructing Store objects and adding it to list.. Commented Oct 20, 2011 at 16:01
  • the problem can be in your code , show it ! Commented Jun 20, 2016 at 11:03

1 Answer 1

2

A 30 second delay during parsing is usually caused by fetching the DTD from the web, especially if it's one of the standard DTDs (like XHTML) found on the w3C web site. If your XML references one of these DTDs you need to make sure that the parser is redirected to a local copy, by using catalogs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.