11

I'm trying use XMLReaderFactory, but this is deprecated. Now, how Can I create a instance of XMLReader?

Igor Rodrigues
  • 131
  • 1
  • 8

2 Answers2

23

The documentation for XMLReaderFactory recommends SAXParserFactory

SAXParserFactory parserFactory = SAXParserFactory.newInstance();
SAXParser parser = parserFactory.newSAXParser();
XMLReader reader = parser.getXMLReader();
Richard
  • 528
  • 2
  • 15
  • @Igor If this post answers your question, please consider to mark the answer as "accepted". Kindly refer to [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers) – fantaghirocco Dec 08 '20 at 14:25
  • 1
    Somehow this new XMLReader doesn't work with the same code as before. Maybe that's why it's not accepted. I'm reverting to the deprecated factory. – Thomas Nov 05 '21 at 11:43
0

XMLReader xmlReader = org.apache.poi.util.XMLHelper.newXMLReader(); Creates a new SAX XMLReader, with sensible defaults.

Keshavram Kuduwa
  • 942
  • 10
  • 40