aspose file tools*
The moose likes XML and Related Technologies and the fly likes SaxParserException: XML document structures must start and end within the same entity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SaxParserException: XML document structures must start and end within the same entity" Watch "SaxParserException: XML document structures must start and end within the same entity" New topic
Author

SaxParserException: XML document structures must start and end within the same entity

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Hi there,

I'm working with a client/server application and using SaxParser for reading in xml. I get the SaxParserException: XML document structures must start and end within the same entity. I understand what that means, but it isn't applicable! The xml data being used is well-formed. I checked the well-formedness with Stylus Studio to make sure. Here's the data:



The parser generally stops around the </bgcolor> tag.
I'm using Eclypse as my IDE. I'm wondering if there's something wrong with it? Or maybe there's something wrong with the class I'm using for reading in the XML? Followng is the class.

Please advise,

Alan

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
My guess is that your input stream is somehow terminated around the element that throws the exception and the parser gets an "end of file" condition.

What generated this XML file?
If the above is not the answer, I would use a programmer's editor to display the contents in HEX to check that the characters are what they appear to be.

Bill
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Damn! You were right! Not all of the generated xml went out to stream. It got truncated. Why is that? Here's my method for sending stuff out the wire:



As you can see, I'm using nio package. Is there something I need to be doing there that prevents it from truncating the String?

Alan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SaxParserException: XML document structures must start and end within the same entity