From: Jano Svitok Date: 2007-09-21T18:29:43+09:00 Subject: Re: Parse XML that isn't well formed On 9/20/07, Milo Thurston wrote: > Alex LeDonne wrote: > > Note that there should be no - the line at the top is a > > declaration, not an opening tag. Where did come from? What > > happens if you remove that from the data? > > > Good point about the XML. Unfortunately, these are the files I have > received and have to deal with them for now. > > Removing the final tag gives: > > .file.xml:3: parser error : Extra content at the end of the document > myserver.edu > ^ > rake aborted! You should have done two things: 1. add root node (with closing just before ) AND 2. remove the trailing Then it'll be fine. in your case it's easy: data.gsub('?>', '?>').gsub('', '')