This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Michael O'Connor
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20966
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic