class Solr::Response::Xml

Attributes

doc[R]
status_code[R]
status_message[R]

Public Class Methods

new(xml) click to toggle source
Calls superclass method Solr::Response::Base::new
# File lib/solr/response/xml.rb, line 19
def initialize(xml)
  super
  # parse the xml
  @doc = REXML::Document.new(xml)

  # look for the result code and string
  # <?xml version="1.0" encoding="UTF-8"?>
  # <response>
  # <lst name="responseHeader"><int name="status">0</int><int name="QTime">2</int></lst>
  # </response>
  result = REXML::XPath.first(@doc, './response/lst[@name="responseHeader"]/int[@name="status"]')
  if result
    @status_code =  result.text
    @status_message = result.text  # TODO: any need for a message?
  end
rescue REXML::ParseException => e
  raise Solr::Exception.new("invalid response xml: #{e}")
end

Public Instance Methods

ok?() click to toggle source
# File lib/solr/response/xml.rb, line 38
def ok?
  return @status_code == '0'
end