Friday, May 1, 2009

Create dynamic meta tag for amazon webservice top selling products, C# asp.net

Creat dynamic meta tag for amazon webservice top selling products, C# asp.net 

void getTags(string rssURL)
    {
        string strLSTPrice;
        string strPrice;
        //ItemnoCnt = Itemno;
        XmlDocument doc = new XmlDocument();
        //  Response.Write(rssURL);
        doc.Load(rssURL);

        XmlNodeList lstItems = doc.GetElementsByTagName("item");
        int cols = lstItems.Count - 1;

        for (int i = 1; i <= cols; i++)
        {
            XmlNode nItem = lstItems[i];
            foreach (XmlNode nChild in nItem.ChildNodes)
            {
                if (nChild.Name == "title") //string compare !
                {
                    String strURL = nChild.InnerXml; //our data !
                    strdecpa = strdecpa + " " + strURL.ToString() + ",";
                    strtitlepa = strURL.ToString();

                    if ((i + 1).ToString() != null)
                    {
                        Page.Title = "Sports Cheap Deals - " + strtitlepa.Trim()+" and many more";
                    }
                }
            }
        }
        HtmlMeta metaDesc = new HtmlMeta();
        metaDesc.Name = "description";
        if (strdecpa != null)
        {
            metaDesc.Content = "Find Online Sports Cheap Deals and coupons on " + strdecpa.Trim() + "only at sportsdeals.net ";
        }

        Page.Header.Controls.Add(metaDesc);
        HtmlMeta metaKey = new HtmlMeta();
        metaKey.Name = "keywords";
        if (strdecpa != null)
        {
            metaKey.Content = strdecpa.Trim().Replace(" ", ",").Replace(",,", ",") + " coupons, online , hot deals  ";
        }
        Page.Header.Controls.Add(metaKey);

    }
}

 

No comments: