Posting XML

6 views
Skip to first unread message

JesseQA

unread,
Mar 9, 2011, 2:49:51 AM3/9/11
to nokogiri-talk
I am trying to post an XML file but it does not seem to do anything.
Can someone take a look at this code and tell me if it looks correct?
Thank you!

require 'rubygems'
require 'net/https'
require 'net/http'
require 'uri'
require 'nokogiri'

url = "http://mydomain.com/Will.do?method=ntf"
uri = URI.parse(url)

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if (uri.scheme == 'https')

f = File.open('my.xml','r')
data = Nokogiri::XML(f)
f.close

headers = {'Content-Type' => 'text/xml'}

resp, body = http.post(uri.path, data.to_xml, headers)
Reply all
Reply to author
Forward
0 new messages