မိတ္ေဆြရဲ႔ Web site ထဲမွာ DailyHoroscope ထည့္ခ်င္သလား။ Yahoo ရဲ႔ Daily Horoscope ကို RSS format (XML format) န႔ဲ ယူၿပီး ကိုယ့္ဘာသာကိုယ္ Javascript (သို႔) ASP.NET နဲ႔ RSS Reader ေလးေရးၿပီး ဆြဲထည့္လို႔ရတယ္။
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=arieshttp://www.shokk.com/cgi-bin/astrology_rss.pl?tid=taurus
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=gemini
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=cancer
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=leo
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=virgo
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=libra
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=scorpio
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=sagittarius
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=capricorn
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=aquarius
http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=pisces
ေအာက္က Source-Code ကေလးကေတာ့ ASP.NET, C# နဲ႔ေရးထားတဲ့ RSS Reader ေလးပါ။ XmlTextReader ကို သံုးထားပါတယ္။
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
string myUrl = Request.QueryString["rss"]!=null? "http://www.shokk.com/cgi-bin/astrology_rss.pl?tid="+Request.QueryString["rss"].Trim(): "http://www.shokk.com/cgi-bin/astrology_rss.pl?tid=aries";
XmlTextReader reader = new XmlTextReader(myUrl);
DataSet ds = new DataSet();
try
{
ds.ReadXml(reader);
myGrid.DataSource = ds.Tables["item"];
myGrid.DataBind();
}
catch{}
}
</script>
<form runat="server">
<asp:DataGrid ID="myGrid" runat="server" AutoGenerateColumns="false" Width="100%" ShowFooter="false" ShowHeader="false" BorderStyle="None" GridLines="None" Font-Name="tahoma" Font-Size="9">
<columns>
<asp:TemplateColumn>
<ItemTemplate><div align="center"><a href="<%#DataBinder.Eval(Container.DataItem,"link")%>" target="_blank" style="color:blue;text-decoration:underline;font-size:12pt;">
<strong><%#DataBinder.Eval(Container.DataItem,"title")%></strong>
</a></div>
<div align="center">
<b><%#DataBinder.Eval(Container.DataItem,"Description")%></b>
<br/>
<a href="<%#DataBinder.Eval(Container.DataItem,"link")%>" target="_blank" style="color:green;font-size:7pt;">
<%#DataBinder.Eval(Container.DataItem,"link")%>
</a>
</div>
</ItemTemplate>
</asp:TemplateColumn>
</columns>
</asp:DataGrid>
</form>
No comments:
Post a Comment