Hi guys, I have a small problem
I am writing a program which adds informations about broken systems in my company.
Customers are informed about new events (outages) via RSS (XML) channels.
My program simply download xml from the web page and give a possibility to add new items (events) to the existing file, and then upload it back to the server...
My xml file looks like that:
?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Testowo Inc.</title>
<link>www.wp.pl</link>
<description>Testowa wersja XML dla RSS via Outlook</description>
<copyright>me:-)</copyright>
<ttl>5</ttl>
<item>
<title>WMS sobie padnie</title>
<description>
WMS
Jakis sobie tam opis..
</description>
<link>http://www.jakis.workpoint.wms.html</link>
<pubDate>2011-07-23T14:34:00+02:00</pubDate>
</item>
<item>
<title>WCP sobie padnie</title>
<description>
WCP
Jakis sobie tam opis..
</description>
<link>http://www.jakis.workpoint.wcp.html</link>
<pubDate>2011-07-23T14:34:00+02:00</pubDate>
</item>
</channel>
</rss>
All I want is a code which will add me new item to this file...
new item with new description, new link and date...
so after save it should look like that:
?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Testowo Inc.</title>
<link>www.wp.pl</link>
<description>Testowa wersja XML dla RSS via Outlook</description>
<copyright>me:-)</copyright>
<ttl>5</ttl>
<item>
<title>WMS sobie padnie</title>
<description>
WMS
Jakis sobie tam opis..
</description>
<link>http://www.jakis.workpoint.wms.html</link>
<pubDate>2011-07-23T14:34:00+02:00</pubDate>
</item>
<item>
<title>WCP sobie padnie</title>
<description>
WCP
Jakis sobie tam opis..
</description>
<link>http://www.jakis.workpoint.wcp.html</link>
<pubDate>2011-07-23T14:34:00+02:00</pubDate>
</item>
<item>
<title>NEW ENTRY</title>
<description>
NEW ENTRY
</description>
<link>NEW ENTRY</link>
<pubDate>NEW DATE</pubDate>
</item>
</channel>
</rss>
My current code doesn't work and it looks like that:
private void load_xml(string xml)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(Application.StartupPath + "\\RSS\\" + xml + ".xml");
//XmlNode xNode = xDoc.CreateNode(XmlNodeType.Element, "add", "");
xDoc.CreateElement("item");
xDoc.CreateAttribute("item", "NEW ENTRY");
xDoc.CreateElement("description");
xDoc.CreateAttribute("description", "NEW ENTRY");
xDoc.Save(Application.StartupPath + "\\RSS\\" + xml + ".xml");
}
THX for help!