Without seeing the code it's kind of difficult to pinpoint the problem - but based on the error it sounds like you're reading some XML somewhere (either stored in a variable or directly from a file) and the XML is [somehow] incomplete or contains some non-parseable characters, and thus you get "Premature end of file".