tags:

views:

371

answers:

0

Good afternoon all, I was trying to post an XML document via net/http to a url, though (I think) I've structured it well but it gives me an error"xml document structures must start and end within the same entity" This is a copy of my code

require 'rexml/document'
include REXML
doc2 = Document.new
doc2.add_element("feed", {"xmlns" => "http://www.w3.org/2005/Atom", "xmlns:opensearch" => "http://a9.com/-/spec/opensearchrss/1.0/"})
doc2.root.add_element("entry",
                                {"xmlns" => "http://www.w3.org/2005/Atom"})
entry = doc2.root.elements[1]
    title = Element.new("title")
                    #{"type"=>"text"})
                         title.text = "Me"
entry.elements << title
        content = Element.new("content")
                    #{"type"=>"xhtml"})
            content.add_element("div")
            content.elements["div"].text = "You are there"
                entry.elements << content
headers = { 'Content-Type' => 'application/atom+xml'}
http = Net::HTTP.new('www.blogger.com')
pathss = "/feeds/#{$blogID}/posts/default"
res, data1 = http.post(pathss, doc2, headers)
puts res.body

Please i would appreciate any response