# File rexml/element.rb, line 879
    def Element.parse_stream source, listener
      begin
	# Get the next tag
	name, closed, attrs = base_parser(source)
	attrs.each { |ar| ar[1,1] = [] }
	listener.tag_start name, attrs
	unless closed
	  while true
	    md = source.match(/\A(\s*[^>]*>)/um)
	    raise ParseException.new("malformed XML: bad content", source, 
				     self) unless md
	    line = md[1]
	    return if line.nil?
	    case line
	    when /\A<[\w_:]/um
	      Element.parse_stream source, listener
	    when /\A<\//um
	      break
	    when CData::START_RE
	      CData.parse_stream source, listener
	    when Comment::START_RE
	      Comment.parse_stream source, listener
	    when Instruction::START_RE
	      Instruction.parse_stream source, listener
	    else
	      Text.parse_stream source, listener
	    end
	  end
	  if source.match(Regexp.new("^\s*<\/#{name}\s*>", Regexp::MULTILINE, 'u'), true)
	    listener.tag_end name
	  else
	    raise ParseException.new( "Missing end tag for #{name}", 
				     source, self )
	  end
	else
	  listener.tag_end name
	end
      rescue ParseException
	$!.source = source
	$!.element = self
	raise
      rescue Exception
	raise
	old_ex = $!
	raise ParseException.new("unidentified error", source, self, old_ex)
      end
    end