I would like to parse through and display and picture and description for each 'item'
in an XML file. I can't figure out the image part, and I've only been able to concatenate the 'description'
to display it:
.ASPX:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="imgAmberIMG" runat="server" />
<asp:Label ID="lblDescription" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Code Behind:
Imports System.Xml.Linq
Imports System.Net
Partial Class AmberAlert
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim amberAlert As XDocument = XDocument.Load("http://www.missingkids.com/missingkids/servlet/XmlServlet?act=rss&LanguageCountry=en_US&orgPrefix=NCMC&state=NY")
For Each xe As XElement In amberAlert.Descendants("item")
lblDescription.Text += (xe.Element("description").Value) + "<br />"
imgAmberIMG.ImageUrl = xe.Element("enclosure").Attribute("url").Value
Next
End Sub
End Class
I'm at the right elements in the tree; I can display the first picture, and I've been able to access all of the 'description' elements. But I need to have each 'item' element display together.
Thanks!