aspose file tools*
The moose likes XML and Related Technologies and the fly likes SAXParseException: 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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SAXParseException: XML document structures must start and end within the same entity." Watch "SAXParseException: XML document structures must start and end within the same entity." New topic
Author

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

Michael O'Connor
Greenhorn

Joined: Oct 11, 2009
Posts: 2
Hi Guys,

I have a simple webservice which has one method which saves an xml 'string' as a blob.
Another method then reads this back in, attempts to parse it & then change a value in it.
Once this is done I want to pass this string on to another class. I do not want to create any files.

However when parsing the XML I have been getting constant errors, the latest of which is:

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

This gets thrown by the line: Document doc = builder.parse(newInputStream);

I have read the input in as a string so I can see that the data looks ok & is all present.

Any help would be greatly appreciated.

The code is below:
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

So... at line 29 you read some, or perhaps all, of the bytes from the blob. Then you make them into a String which isn't referenced anywhere else.

Then at line 39 you pass the rest of the bytes, if there are any left, to the XML parser. This doesn't make much sense. Deleting lines 26 to 32 would make more sense; then you would just be passing the contents of the blob to the parser.
Michael O'Connor
Greenhorn

Joined: Oct 11, 2009
Posts: 2
Lines 26 - 32 were there so I could print out as a string what I was reading back from the database to check if it was valid.

Line 33 introduced a new stream to read the data again as you cannot reuse the existing stream as it has already read the data, this was giving another error.

While aesthetically correct neither of these points are relevant to the issue at hand.

I did manage to fix this however by changing how I was reading the stream in & also by fixing up my data.

Thanks for the comments.

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