[Twisted-Python] How to save the content(string) of a DOM node into a file?

Andrew Bennetts andrew-twisted at puzzling.org
Mon Sep 15 21:17:56 EDT 2003

On Mon, Sep 15, 2003 at 11:17:44AM -0700, suneetha velicheti wrote:
> Hi,
>   I wanted to save the content of a DOM node into a file and want my 
> browser to prompt me with "save as" window. I already set the browser 
> preferences. Right now the content of the node is just displaying in the 
> browser window. Instead of that I want to promt the user to save that 
> content into a file with "save as" option window. Are there any DOM helper 
> methods to do this?

So you're serving XML from a Twisted web server?  I think you want to call
"request.setHeader('content-type', 'application/octet-stream')", or
something like that.  That should convince the browser to save it rather
than display it (this applies to pretty much anything you could serve, not
just XML).

There's also a Content-Disposition header that is supposed to do this, but
I've never been able to figure out how to make it work reliably across
different browsers.


More information about the Twisted-Python mailing list