RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Develop a Mobile RSS Feed the Easy Way : Page 3

Find out how to take your basic web development skills and build a mobile J2ME application.

Your Mobile RSS Feed: Fine-Tuning
Now, you'll want to tidy up some of the HTML in the RSS feed so that it returns only the text. To do so, use this very basic regular expression:

function stripHTML(theRawText) {

  var myRegEx2 = /\<(.|\n)+?\>/;
  var myOutput2 = theRawText;
  myOutput2 = myOutput2.replace(myRegEx2, "");
  return myOutput2;	 
Then, call the following from your parseFunction code:

//now set the XML document on Cascada's index.html page
document.getElementById("desc" + 0 ).innerText = stripHTML(node.data);	
The article now appears in plain text (see Figure 6).

Figure 6. Plain Text: The article now appears in plain text.
Figure 7. Parsing the XML: The updated function parses the XML, with this result.

Now to be useful, you can go grab the rest of the headlines by putting a few more response areas on the index.html, which will hold the data. You can also get rid of the placeholder text, so the index.html page looks like this:

<div id="response" class="response" >

<div id="item0" class="item" >
<div id="title0" class="title" ></div>
<div id="date0" class="date" ></div>
<div id="desc0" class="description" ></div>
</div> <!--item-->

<div id="item1" class="item" >
<div id="title1" class="title" ></div>
<div id="date1" class="date" ></div>
<div id="desc1" class="description" ></div>
</div> <!--item-->
Now, you can update parseFunction to loop through each entry in the RSS feed. Then your app should look like Figure 7.

Use the following line to add an icon in the index.html file:

<link rel="icon" href="res/128x128rss.png"/>
This line can be used to include the actual image in the project.

You can also add links from the feed and call the mobile browser, or let the user pick which feeds they want to see. For now, however, this does the trick. It's also a good idea to add some error and exception handling.

Figure 8. Published! Viewing your application at dev.cascadamobile.com.
Figure 9. It's Free: Mobile ad at the bottom pays for your free publishing.

Your Mobile RSS Feed: Publishing
Now, it's time to publish your application from the Eclipse plug-in. The first step is to register for free and get your username and password. After you follow the steps and upload your file, you'll be able to see your application (Figure 8).

Figure 10. A Real-Life View: A screenshot of the final application on a Motorola phone.

Next, send it out to yourself by clicking on the application and following the steps there. (Figure 9 is a screen shot from a Motorola phone. The little text ad at the bottom is why this whole thing is free for you, me, or any other developer with a cool idea.

Figure 10 shows a screenshot of the final application on a Motorola phone.

Mobile Development Is a Breeze
I know I couldn't have pulled this off in an hour coding in J2ME! Using your basic web development skills to build apps, you avoid the hassles of learning the your way around J2ME. This saves time, money, and headaches.

Vladimir Khomutov is a developer forf 3 Acts Interactive.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date