# File lib/yadis/xrds.rb, line 51
  def parse_xml(xml_text)   
    begin
      xml = @xml = REXML::Document.new(xml_text)
    rescue
      raise ArgumentError, "Can't parse XRDS"
    end
    
    if xml.root.nil?
      raise ArgumentError, "No document root"
    end

    xrd = self.last_xrd(xml.root)
    raise ArgumentError, "No XRD Elements found" if xrd.nil?
   
    @services = {}  # keyed by [service_priority, uri_priority]
    REXML::XPath.each(xrd, 'xrdns:Service', @@namespaces) do |s|
      _create_services(s)
    end
    
    REXML::XPath.each(xrd, 'xrdns:CanonicalID', @@namespaces) do |c|
      canonical_id = c.text.strip
      if canonical_id.length > 0
        self.services.each {|s| s.canonical_id = canonical_id}
      end
    end

  end