With my C# code page I show the RSS news in the browser and with this code the insert in DB is only for the general title of the news and not for single title, description and pubdate of single news.
I would greatly appreciate any help you can give me in working this problem, thank you.
Code behind:
Stream stream = resp.GetResponseStream();
XmlTextReader reader = new XmlTextReader(stream);
reader.XmlResolver = null;
XmlDocument doc = new XmlDocument();
doc.Load(reader);
xmlRSS.Document = doc;
XmlNodeList dataNodes = doc.SelectNodes("/title");
OdbcCommand command;
OdbcDataAdapter adpter = new OdbcDataAdapter();
foreach (XmlNode node in dataNodes)
{
string titlenew = node.SelectSingleNode("//title").InnerText;
string descriptionnew = node.SelectSingleNode("//description").InnerText;
string pubDatenew = node.SelectSingleNode("//pubDate").InnerText;
string sql = "insert into Product (title, description, pubdate) values (?,?, " +
" STR_TO_DATE(?, '%a, %d %b %Y %H:%i:%s GMT'));";
connection.Open();
command = new OdbcCommand(sql, connection);
command.Parameters.AddWithValue("param1", titlenew.ToString());
command.Parameters.AddWithValue("param2", descriptionnew.ToString());
command.Parameters.AddWithValue("param3", pubDatenew.ToString());
adpter.InsertCommand = command;
adpter.InsertCommand.ExecuteNonQuery();
connection.Close();
}
xslt file
Replies
Know the answer? Post it — somebody with the same question will find it here.