Sebaku
Sebaku

Reputation: 31

Question about using StAX with an endless stream of xml files

I have a server running that sends one xml file every second (which eventually needs to be upgraded to 800 files/second). The client I wrote that listens to the server, processes the first file perfectly fine, but as soon as the 1st file is completely processed and it tries to go to the second file, I get the following error:

javax.xml.stream.XMLStreamException: ParseError at [row,col]:[164,6] Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.

I'm assuming this is caused because it is reading the start if the next xml file <?xml version="1.0" encoding='null' standalone='no'?> and that causes the error?

Upvotes: 2

Views: 74

Answers (1)

Tomasz Pieczkowski
Tomasz Pieczkowski

Reputation: 110

This exception is caused, like you assumed, by XML declaration (which is part of prolog) not being before first element in the document according to spec. Depending on what implementation you use to read the file you should reset your reader or close and create new instance for each file.

Upvotes: 1

Related Questions