Over a million developers have joined DZone.

Save Text Page As A File

// description of your code here
I am developing a mobile Application that users can view their Blog
posts and also make posts to their blogs via a mobile phone. I also
want it in such a way that the users can save a particular post of
interest for future references or to read when they are offline. What
I intend doing is to save the post as a text file and save the title,
Author, Date-Published and category in the database. I should also
keep record of the number of entries such that it prompts one to
delete an item if the number of saved items is up to 5. Please can
someone help me with how to go about saving.

// insert code here..
def view_each_post
	@id = @params['id']
	#to accept the global variable as an instant variable
	#@post_id = $post_id
	$post_id.each_with_index{  | id,  index|   
		if id == @id
			@content = $content[index]
			@post_id = $post_id[index]
			@published = $published[index]
			@category = $category[index]
			@post_title = $post_title[index]
		# Get comment for each post 
		url = URI.parse('http://www.blogger.com')
		@res = Net::HTTP.start(url.host, url.port) {|http|
	content = Array.new
	name = Array.new
	docs =  REXML::Document.new(@res.body)
	# content of the comment
	docs.elements.each("*/entry/content"){ |element| 

		if element.text == nil or element.text == ""
			content << 'No comments yet for this post'
                    content << element.text
	docs.elements.each("*/entry/author/name"){ |element|  
		if name.include?("#{ element.text}") == false
		name <<  element.text  
	@author = name
	@comment = content
	@author_says = "#{@author} Said:"
	render :action => :view_each_posts


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}