# How do you access a remote XML file?

**URL:** <https://www.ruby-forum.com/t/how-do-you-access-a-remote-xml-file/191247>\
**Category:** Rails\
**Created:** [July 8, 2010, 8:21am UTC](https://www.ruby-forum.com/t/how-do-you-access-a-remote-xml-file/191247 "2010-07-08T08:21:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8c91f0/32.png) [@ali](https://www.ruby-forum.com/u/ali)\
**Post date:** [July 8, 2010, 8:21am UTC](https://www.ruby-forum.com/t/how-do-you-access-a-remote-xml-file/191247/1 "2010-07-08T08:21:14Z")

</div>

Hi, I’m trying to get a captch thing running from  
[http://textcaptcha.com/](http://textcaptcha.com/)  
which displays an XML file when you trail a key on that URL. I’ve  
tried this: @captcha = Net::HTTP.get\_print URI.parse(‘http://  
[textcaptcha.com/api/8wcmmrp2tzoc0k484kkwwkwcsdbpk70q](http://textcaptcha.com/api/8wcmmrp2tzoc0k484kkwwkwcsdbpk70q)’) in the  
controller of the file that I want to have access to the data, but  
nothing is displayed in the @captcha variable. If I direct my web  
browser to that URL, however, I see the correct output.

I’m requiring ‘net/http’ and ‘uri’ in the controller. Am I missing  
something?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8c91f0/32.png) [@ali](https://www.ruby-forum.com/u/ali)\
**Post date:** [July 8, 2010, 9:20am UTC](https://www.ruby-forum.com/t/how-do-you-access-a-remote-xml-file/191247/2 "2010-07-08T09:20:58Z")

</div>

On Jul 8, 7:20 am, Ali [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi, I’m trying to get a captch thing running fromhttp://textcaptcha.com/  
> which displays an XML file when you trail a key on that URL. I’ve  
> tried this: @captcha = Net::HTTP.get\_print URI.parse(‘http://  
> [textcaptcha.com/api/8wcmmrp2tzoc0k484kkwwkwcsdbpk70q](http://textcaptcha.com/api/8wcmmrp2tzoc0k484kkwwkwcsdbpk70q)’) in the  
> controller of the file that I want to have access to the data, but  
> nothing is displayed in the @captcha variable. If I direct my web  
> browser to that URL, however, I see the correct output.
> 
> I’m requiring ‘net/http’ and ‘uri’ in the controller. Am I missing  
> something?

All get\_print is supposed to do is output the data to the console.  
get\_response will instead return a Net::HTTPResponse object which you  
can play around with.

Fred

---

<div class="post-metadata">

**Author:** ![ali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8c91f0/32.png) [@ali](https://www.ruby-forum.com/u/ali)\
**Post date:** [July 8, 2010, 1:09pm UTC](https://www.ruby-forum.com/t/how-do-you-access-a-remote-xml-file/191247/3 "2010-07-08T13:09:55Z")

</div>

Thank you sir!

On Thu, Jul 8, 2010 at 7:19 PM, Frederick C.  
\<removed\_email\_address@domain.invalid
