×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Sep 2007
    Posts
    54

    Question Problem extracting file from HTTP response

    Hi, I am currently writing a program that sends a HTTP get to a server and along with the HTTP response, the server sends me a XML file. What I am trying to do is to save this file. However i encountered the problem whereby the whole response message is saved. Below is an example of what was saved in the file.

    <XML>....<info></info>...</XML>System.Threading.ThreadABortException:Thread was being aborted. at System.Threading. Thread.Abort(object stateinfo) at System Web. HttpResponse.End()at......

    The code i used is:
    Code:
    status1, reason1, read1 = post_multipart(host, selector, fields, files)
    if status1 > 0:
    		f = file(path_xml, 'wb')
    		f.write(read1)
    		f.close()
    		appuifw.note(u"Query response received", "info")
    		read_xml(path_xml)
    def read_xml(path_xml):
    	print path_xml
    	doc = ET(file=path_xml)
    	#find the "path" element by tag name
    	body = doc.getroot().findall("info")[0]
    	#print body
    	download_path = body.text
    	print download_path
    	download_query(download_path)
    Can anyone help me to either save the xml without the rest of the HTTP response msg or teach me how to retrieve the data for the element info. When I tried to real xml, I encountered error due to the unwanted information in the xml file.

    I tried google and search but could get no answer. So pls someone help me out
    Last edited by nick_santa83; 2008-02-12 at 04:25.

  2. #2
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Helsinki
    Posts
    376

    Re: Problem extracting file from HTTP response

    <XML>....<info></info>...</XML>System.Threading.ThreadABortException:Thread was being aborted. at System.Threading. Thread.Abort(object stateinfo) at System Web. HttpResponse.End()at......
    This looks like invalid XML code. You need to fix XML generation at the server side or clean up response string manually (wrong way to go).
    Mikko Ohtamaa

    http://mfabrik.com
    http://blog.mfabrik.com

  3. #3
    Regular Contributor
    Join Date
    Sep 2007
    Posts
    54

    Re: Strange that no one ever has this problem

    ok. thanks alot

Similar Threads

  1. Strange problem "java.lang.Error 105"
    By aadipa in forum Mobile Java General
    Replies: 6
    Last Post: 2009-10-22, 09:21
  2. Strange problem while installing Carbide.C++ express
    By jugnoyasir in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 4
    Last Post: 2008-10-06, 20:19
  3. strange problem !!!
    By metebalci in forum Mobile Java General
    Replies: 0
    Last Post: 2005-09-30, 08:41
  4. VERY strange memory full problem..
    By etamburini in forum Mobile Java General
    Replies: 9
    Last Post: 2005-05-17, 15:50
  5. very strange problem
    By victorh81 in forum Symbian
    Replies: 1
    Last Post: 2003-12-09, 09:09

Posting Permissions

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