# File lib/casclient/responses.rb, line 6
    def check_and_parse_xml(raw_xml)
      begin
        doc = REXML::Document.new(raw_xml)
      rescue REXML::ParseException => e
        raise BadResponseException, 
          "MALFORMED CAS RESPONSE:\n#{raw_xml.inspect}\n\nEXCEPTION:\n#{e}"
      end
      
      unless doc.elements && doc.elements["cas:serviceResponse"]
        raise BadResponseException, 
          "This does not appear to be a valid CAS response (missing cas:serviceResponse root element)!\nXML DOC:\n#{doc.to_s}"
      end
      
      return doc.elements["cas:serviceResponse"].elements[1]
    end