• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Sheriff
Posts: 28322
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
A teeny tiny vulgar attempt to get you to buy our stuff
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic