Resolves the xml stream parsing error

Parsing a continous xml stream was buggy. This pull request contains some fixes to solve this issue