Does it support any saxophone libraries at an early stage, depending on some conditions?

I have an xml file that looks like this:

<root> <application-key>ABC2349293493</application-key> ... .. </root> 

The XML file is quite large, and I just need to get the application key to find out if this request should be restricted.

My server gets knocked, so I need a way to evaluate limit requests without having to read all of the xml.

DOM is out of the question due to the amount of memory.

I am pleased with SAX, but with xerces you cannot stop processing xml since it is a push model. The only way I know so far is an exception.

Does any of the other saxophonic libraries support early withdrawal?

+4
source share
2 answers

StAX (Streaming Api for XML) pulls out the parser. Choosing the right implementation is also important: Best StAX implementation .

PS I still think that the SAX way of doing things (throwing an exception) is easier.

+3
source

An exception is indeed the only option in the specification available to exit the parsing process. As indicated by Java. Sax parser. How to manually break parsing? or How to stop parsing an XML document using SAX at any time? .

Switch to the parser if you REALLY don't want to use an exception, but I don't think it really matters.

+2
source

Source: https://habr.com/ru/post/1387807/


All Articles