...

View Full Version : xml .net newbie



janetb
07-08-2009, 09:24 PM
Had a repeater giving out an rss xml data feed, but it took too long to load, so I'm using an ajax incremental page loader and need to get the xml into an innerhtml format so I can write it back to the page's div tag via a web service. I've tried researching for days, but I'm having trouble getting the description piece (the title and link come through fine) and wondered if anyone would be willing to explain it and help out?


<asp:Repeater ID="rptr" runat="server" DataSourceID="XmlDataSource">
<ItemTemplate>
<<%# XPath("title") %><br />
<%# XPath("description") %><a href='<%# XPath("link") %>'>...details</a><br /><br />
</ItemTemplate>
</asp:Repeater>
</fieldset>
<asp:XmlDataSource ID="XmlDataSource" runat="server" DataFile="http://www.exploreasheville.com/rss-feeds/asheville-happenings/index.aspx" XPath="rss/channel/item" >
</asp:XmlDataSource>

The following works with only (0) and (1), until I try to pull back the description (I'm guessing (2) because of xml page structure below), then I only get [object Object] .


Try
Dim myStr As String
Dim m_xmld As System.Xml.XmlDocument
Dim m_nodelist As System.Xml.XmlNodeList
Dim m_node As System.Xml.XmlNode
m_xmld = New System.Xml.XmlDocument()
m_xmld.Load("http://www.exploreasheville.com/rss-feeds/asheville-happenings/index.aspx")
m_nodelist = m_xmld.SelectNodes("rss/channel/item")
'Loop through the nodes
For Each m_node In m_nodelist
'Get the Element Values
Dim titleValue = m_node.ChildNodes.Item(0).InnerText
Dim linkValue = m_node.ChildNodes.Item(1).InnerText
myStr &= titleValue & "<br />" & "description to follow&nbsp;<a href='" & _
linkValue & "'>...details</a><br />"
Next
Catch errorVariable As Exception
'Error trapping
myStr &= errorVariable.ToString()
End Try
Return myStr

When I view the source of the page, this is the structure:


<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:rei="http://r-effects.com">
<channel>
<title>Asheville Happenings</title>
<description>Featured upcoming happenings in Asheville, North Carolina.</description>
<link>http://www.exploreasheville.com</link>
<language>en-us</language>
<copyright>Buncombe County Tourism Development Authority</copyright>
<image><title /><URL /><link /></image>

<item>
<title>Apr 25, 2009 - Sep 20, 2009: The Legacy Continues</title>
<link>http://www.tada.com/event-calendar/event-details/index.aspx?eid=2962</link>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum