c# - How does samachar.com use google news rss? -
how website www.samachar.com use google news rss?
i looking functionality coded in asp.net. have code not working google news rss.
code:
public void createrss(string path, int maxitem1, string opennewwindow,string lengthoof_decs) { xmldocument doc = null; xmltextreader rssreader = null; label doclbl = null; label snolbl = null; try { try { rssreader = new xmltextreader(path); } catch (exception) { return; } if (rssreader == null) { return; } doc = new xmldocument(); try { doc.load(rssreader); } catch (exception) { return; } if (doc == null) { return; } readdoc(doc, maxitem1, opennewwindow, lengthoof_decs); } catch (exception) { throw; } { doc = null; rssreader = null; doclbl = null; snolbl = null; } } public void readdoc(xmldocument rssdoc, int maxitem2, string opennewwindow, string lengthoof_decs) { datatable dt = new datatable(); int maxitems = 0; ; dt.columns.add("title"); dt.columns.add("desc"); dt.columns.add("url"); xmlnode noderss = null; xmlnode nodechannel = null; xmlnode nodeitem = null; try { if (rssdoc == null) { return; } // loop <rss> tag (int = 0; < rssdoc.childnodes.count; i++) { // if rss tag if (rssdoc.childnodes[i].name == "rss") { noderss = rssdoc.childnodes[i]; break; } } if (noderss == null) { return; } (int = 0; < noderss.childnodes.count; i++) { if (noderss.childnodes[i].name == "channel") { nodechannel = noderss.childnodes[i]; break; } } if (nodechannel == null) { return; } // loop <title>, <link>, <description> , other tags (int = 0; < nodechannel.childnodes.count; i++) { string title = ""; string desc = ""; string url=""; if (nodechannel.childnodes[i].name == "item") { nodeitem = nodechannel.childnodes[i]; if (nodeitem["title"] != null) { title = nodeitem.innerxml.tostring(); ; int pos1 = title.indexof("<title>") + "<title>".length; int pos2 = title.indexof("</title>"); title = title.substring(pos1, pos2 - pos1); //<![cdata[ title= title.replace("cdata", "").replace ("%","").replace("<", "").replace("!", "").replace("[", "").replace("<![cdata[", "").replace(" ", "").replace("]]>", "").replace("]", "").replace(">", ""); } if (nodeitem["description"] != null) { desc = nodeitem.innerxml.tostring(); ; int pos1 = desc.indexof("<description>") + "<description>".length; int pos2 = desc.indexof("</description>"); desc = desc.substring(pos1, pos2 - pos1); //////////////////////////////////////////// try { int g1 = desc.indexof("<img"); int g2 = desc.indexof(">") + ">".length; if (g1 > -1 && g2 > -1) { string desc1 = desc; desc1 = desc1.substring(g1, g2 - g1); desc = desc.replace(desc1, ""); } } catch (exception ehge) { } try { int g1 = desc.indexof("<img"); int g2 = desc.indexof(">") + ">".length; if (g1 > -1 && g2 > -1) { string desc1 = desc; desc1 = desc1.substring(g1, g2 - g1); desc = desc.replace(desc1, ""); } } catch (exception ehge) { } try { int g1 = desc.indexof("<img"); int g2 = desc.lastindexof(">")+">".length; if (g1 > -1 && g2 > -1) { string desc1 = desc; desc1 = desc1.substring(g1, g2 - g1); desc = desc.replace(desc1, ""); } } catch (exception ehge) { } (int d = 0; d <= 5; d++) { try { int g1 = desc.indexof("<"); int g2 = desc.indexof(">") + ">".length; if (g1 > -1 && g2 > -1) { string desc1 = desc; desc1 = desc1.substring(g1, g2 - g1); desc = desc.replace(desc1, ""); } } catch (exception ehge) { } } (int d = 0; d <= 5; d++) { try { int g1 = desc.indexof("<"); int g2 = desc.indexof(">") + ">".length; if (g1 > -1 && g2 > -1) { string desc1 = desc; desc1 = desc1.substring(g1, g2 - g1); desc = desc.replace(desc1, ""); } } catch (exception ehge) { } } //////////////////////////////////////////// desc = desc.replace("cdata", "").replace("<", "").replace ("%","").replace("!", "").replace("[", "").replace("<![cdata[", "").replace(" ", "").replace("]]>", "").replace("]", "").replace(">", ""); ; if (lengthoof_decs.trim() != "all") { try { string tempdesc = desc; tempdesc = tempdesc.substring(0, convert.toint16(lengthoof_decs)); tempdesc = tempdesc + " ..".replace("cdata", "").replace("<", "").replace("!", "").replace("[", "").replace("<![cdata[", "").replace(" ", "").replace("]]>", "").replace("]", "").replace(">", ""); desc = tempdesc; } catch (exception ee) { // desc = desc.substring(pos1, pos2 - pos1); } } url = nodeitem.innerxml.tostring(); ; pos1 = url.indexof("<link>") + "<link>".length; pos2 = url.indexof("</link>"); url = url.substring(pos1, pos2 - pos1); url = url.replace("amp;", "").replace("cdata", "").replace("<", "").replace("!", "").replace("[", "").replace("<![cdata[", "").replace(" ", "").replace("]]>", "").replace("]", "").replace(">", ""); } if (nodeitem["pubdate"] != null) { } datarow dr = dt.newrow(); dr["title"] = title; dr["desc"] = desc; dr["url"] = "http://www.desikhabar.in/show/?move="+url; dt.rows.add(dr); maxitems = maxitems + 1; if (maxitems == maxitem2 ) { break; } } } } catch (exception) { throw; } { this.abc(dt, maxitem2, opennewwindow, lengthoof_decs); } } public void abc(datatable dt, int maxiem, string opennewwindow, string lengthoof_decs) { try { if (opennewwindow == "1") { (int = 0; < maxiem; i++) { opennewwindow = "_blank"; response.write(" <li> <a target='" + opennewwindow + "' class='h-linkn' href='" + dt.rows[i]["url"].tostring() + "' title='" + dt.rows[i]["title"].tostring().replace("'", " ") + "'>" + dt.rows[i]["title"].tostring() + "</a> </li>"); if (lengthoof_decs.trim () !="0") { response.write(" <p>"+dt.rows[i]["desc"].tostring ()+"</p> "); } } } else { (int = 0; < maxiem; i++) { response.write(" <li> <a class='h-linkn' href='" + dt.rows[i]["url"].tostring() + "' title='" + dt.rows[i]["title"].tostring().replace("'", " ") + "'>" + dt.rows[i]["title"].tostring() + "</a> </li>"); if (lengthoof_decs.trim() != "0") { response.write(" <p>" + dt.rows[i]["desc"].tostring() + "</p> "); } } } } catch (exception ea) { } }
if going read standard rss, @ syndicationfeed int system.servicemodel.syndication namespace.
Comments
Post a Comment