Pages

Showing posts with label experiments. Show all posts
Showing posts with label experiments. Show all posts

Labs

avro-log4j   -  serialization mechanism to provide a layout for log4j

firetester   -  A simple RESTful services testing tool written in Groovy Griffon framework

gitter - Publishes github activities to Twitter

jfilemagic (jfm) is an utility for identifying files using magic numbers or signatures

cometd-chat - a comet based chatter for fun



ImagePrvR - A sample AIR project


ImagePrvr is my first attempt in developing an AIR application which was done within some minutes.It is a simple image browser.
More news were coming from Adobe world.They are going to have an up hand on creating future web user interfaces and multimedia.They have announced the Open Screen Project which remove restrictions on use of the SWF and FLV/F4V specifications.Adobe recently launched a beta version of Adobe Flash Player 10, codenamed "Astro", which is claimed to include better 3D animation support helping create better special effects and Web experiences. "Astro" boasts Adobe's free pixel bender tools that support custom visual effects.I have installed that and the air application was running fine.

This is an experiment.Just try it.In future the interface may change and more features will be added.

Download

A simple RSS parser

Various XML parsing technologies made the content delivery on web very flexible.I am experimenting with various rss parsing methods.One of the straight forward parsing technology is XML Pull Parsing.Xml Pull Parser (in short XPP) is a streaming pull XML parser and should be used when there is a need to process quickly and efficiently all input elements.The method is very flexible and there is no need for xml validation.I think this form is very useful for parsing simple xml documents.The parsing is designed by programmer itself requesting the parsing for each elements.He can omit elements and its subtree which are not needed.RSS are syndications through xml data.So a simple RSS parsing can be done by XPP method.The limitation that restricts XPP to a subset of XML documents is that it does not support entities, comments, or processing instructions in the document. XPP creates a document structure consisting only of elements, attributes (including Namespaces), and content text. This is a serious limitation for some types of applications.Anyway I try here to make a sample code.In this code an rss feed is read and create a string as a content inside div tag , so that the string can attach as innerhtml data for a dynamic page.I want to make it as a webservice, so that the content delivery can happen as a service.

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using System.IO;
using System.Xml;

namespace SampleWebService
{
public class Parser
{
StringBuilder sbString = new StringBuilder();
StringBuilder sbTempString = null;

public string GetXMLData()
{

XmlTextReader xtrReader = new XmlTextReader("http://rss.cnn.com/rss/cnn_world.rss");
xtrReader.WhitespaceHandling = WhitespaceHandling.None;
xtrReader.MoveToContent();


while (xtrReader.Read())
{
switch (xtrReader.NodeType)
{

case XmlNodeType.Element:
BuildElements(xtrReader);
break;

case XmlNodeType.EndElement:
BuildEndElements(xtrReader);
break;
}

}

return sbString.ToString();

}

private void BuildElements(XmlTextReader xtrReader)
{
switch (xtrReader.Name.ToLower())
{

case "item":
sbTempString = new StringBuilder();
sbTempString.Append("<div>");
break;

case "title":
if (sbTempString != null && sbTempString.Length > 0)
{
xtrReader.Read();
sbTempString.Append("<a>").Append(xtrReader.Value).Append( "</a><br />");
}
break;

case "link":
if (sbTempString != null && sbTempString.Length > 0)
{
xtrReader.Read();
sbTempString.Insert(sbTempString.ToString().LastIndexOf("<a") + 2, " href=\"" + xtrReader.Value +"\"");
}
break;

case "description":
if (sbTempString != null && sbTempString.Length > 0)
{
xtrReader.Read();
sbTempString.Append("<p>").Append(xtrReader.Value);
}
break;

}
}


private void BuildEndElements(XmlTextReader xtrReader)
{
switch (xtrReader.Name.ToLower())
{

case "item":
if (sbTempString != null && sbTempString.Length > 0)
{
sbTempString.Append("</div>");
sbString.Append(sbTempString);
}
break;

case "title":

break;

case "link":
break;

case "description":
if (sbTempString != null && sbTempString.Length > 0)
{
sbTempString.Append("</p>");
}
break;

}
}


}
}