Why would I get this error when building the XML document in vb.net

I'm trying to build a web service and it should build a new XML out of an existing XML.the code as follows:\[code\] <WebMethod(CacheDuration:=0, Description:="GroveHallFromRss")> _ Public Function GroveHallFromRss() As XmlDocument Dim webClient As System.Net.WebClient = New System.Net.WebClient() Dim ourUrl As String = "http://123.example.org/RSSSyndicator.aspx?type=N&range=currentyear&expire=Y&location=2-7-165&rssid=18" Dim stream AS Stream stream = webClient.OpenRead(ourUrl) Dim xmlDocument AS XmlDocument = new XmlDocument() xmlDocument.Load(stream) Dim myXml As XmlDocument = new XmlDocument() Using writer As XmlWriter = myXml.CreateNavigator().AppendChild() writer.WriteStartDocument() writer.WriteStartElement("document") For Each item As System.Xml.XmlElement In xmlDocument.Item("item") writer.WriteStartElement("event") writer.WriteElementString("title", item.Item("title").Value) writer.WriteElementString("link", item.Item("link").Value) writer.WriteElementString("description", item.Item("description").Value) writer.WriteEndElement() Next writer.WriteEndElement() writer.WriteEndDocument() End Using Return myXml\[/code\]It gives me an error like this:\[quote\] System.NullReferenceException: Object reference not set to an instance of an object. at Portal.GroveHallFromRss()\[/quote\]The problem seem to be around the line of: \[quote\] For Each item As System.Xml.XmlElement In xmlDocument.Item("item")\[/quote\]But I'm not sure what caused this. Thanks!Here goes the XML:\[code\]<rss version="2.0">-<channel>-<title>title 123</title><cf:treatAs>list</cf:treatAs><link>http://123/default.aspx</link><description>RSS Feed 123 Events Calendar</description>-<item><title>New 123 (6/18/2012)</title>-<link>http://123.aspx?view=EventDetails&eventidn=9751&information_id=19501&type=&rss=rss</link>-<description><table cellpadding="5" cellspacing="0" border="0"><tr><td valign="top"><table cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-bottom:1px;"><b>Start Date:</b>&nbsp;</td><td style="padding-bottom:1px;">6/18/2012</td><td>&nbsp;<b>Start Time:</b>&nbsp;</td><td>8:00 AM</td></tr><tr><td><b>End Date:</b>&nbsp;</td><td>6/18/2012</td><td>&nbsp;<b>End Time:</b>&nbsp;</td><td>4:00 PM</td></tr></table><br />123<br />Room: 123<br /><br />nil</td></tr></table></description><pubDate>Mon, 18 Jun 2012 12:00:00 GMT</pubDate><category>06/18/2012</category></item>+<item><title>123 Orientation (6/19/2012)</title>-<link>http://123/EventList.aspx?view=EventDetails&eventidn=9770&information_id=19539&type=&rss=rss</link>-<description><table cellpadding="5" cellspacing="0" border="0"><tr><td valign="top"><table cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-bottom:1px;"><b>Start Date:</b>&nbsp;</td><td style="padding-bottom:1px;">6/19/2012</td><td>&nbsp;<b>Start Time:</b>&nbsp;</td><td>8:00 AM</td></tr><tr><td><b>End Date:</b>&nbsp;</td><td>6/19/2012</td><td>&nbsp;<b>End Time:</b>&nbsp;</td><td>4:00 PM</td></tr></table><br />123<br />Room: 106<br /><br />nil</td></tr></table></description><pubDate>Tue, 19 Jun 2012 12:00:00 GMT</pubDate><category>06/19/2012</category></item>-<item><title>123 (6/20/2012)</title>-<link>http://123/EventList.aspx?view=EventDetails&eventidn=9789&information_id=19577&type=&rss=rss</link>-<description><table cellpadding="5" cellspacing="0" border="0"><tr><td valign="top"><table cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-bottom:1px;"><b>Start Date:</b>&nbsp;</td><td style="padding-bottom:1px;">6/20/2012</td><td>&nbsp;<b>Start Time:</b>&nbsp;</td><td>8:00 AM</td></tr><tr><td><b>End Date:</b>&nbsp;</td><td>6/20/2012</td><td>&nbsp;<b>End Time:</b>&nbsp;</td><td>4:00 PM</td></tr></table><br />123 Grove Hall<br />Room: 106<br /><br />nil</td></tr></table></description><pubDate>Wed, 20 Jun 2012 12:00:00 GMT</pubDate><category>06/20/2012</category></item></channel></rss>\[/code\]
 
Back
Top