SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help With NET::HTTP ... adding headers...

    So my code goes like this:
    xml = Net::HTTP.get(URI(url))
    xml.add_field 'uid', 'a7610b41dbcb727ec4e05b487d7fc4cbaab790bb'

    but it says add_field is an invalid method, however when I look at the documentation its fine. Does anyone know what I am doing wrong? Thanks
    Have a good day.

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the problem is that
    Code:
    Net::HTTP.get(URI(url))
    will return text and not an XML document. Have a look at the api documentation.

    You have to parse the text in an XML utility to get it into the right format. While looking for an example of how to use an XML parser in this way I found the page below which describes the whole process from grabbing the content via Net::HTTP to parsing the result into an XML object.

    http://developer.yahoo.com/ruby/ruby-xml.html


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •