Parse http login/password protected XML file?

If you have any other suggestion, I’m open. My basic need is to read an
XML file that is located on an HTTP link which is protected with IIS’s
login/password. I need to read some values from this XML file.

I have to read xml files that are accessibles through http with
authentication. That’s why I use mechanize (I was able to successfully
read it with nokogiri on an unprotected site)

My problem is that I can’t get mechanize to recognize these XML files in
order to
use .search on them.

Here is what I tried first - in my view (html file) (Example with an
unprotected file but the real one will be http login/pass protected)

<% agent = %>
<% page = agent.get(“”) %>
<%= page %>

Which returns #Mechanize::File:0x007f9dd602de30. It’s ::File and not
I can’t use a .search on this as it’ll error with undefined
method find for #Mechanize::File:0x007f9dd624cbd0

Mechanize doc says : This is the default (and base) class for the
Pluggable Parsers. If Mechanize cannot find an appropriate class to use
for the content type, this class will be used. For example, if you
download a JPG, Mechanize will not know how to parse it, so this class
will be instantiated.

So I created a class as described here :

My class
class XMLParser < Mechanize::File+
attr_reader :xml
def initialize(uri=nil, response=nil, body=nil, code=nil)
super(uri, response, body, code)`
@xml = xml.parse(body)

and the updated code in my view (html file)

<% agent = %>
<% agent.pluggable_parser[‘text/xml’] = XMLParser %>
<% agent.user_agent_alias = ‘Windows Mozilla’ %>
<% page = agent.get(“”) %>
<%= page %>

or even

<% agent = %>
<% agent.pluggable_parser.xml = XMLParser %>
<% page1 = agent.get(‘’) # =>
CSVParser %>
<%= page1 %>

Still returns #Mechanize::File:0x007f9dd5253b48

I even tested the exact code (CSVParser -
and tried loading a csv file that is still seen as a ::File.

What am I doing wrong ? Any other gem (or built in) suggestions ?