Hi,
I am wondering what I might be doing wrong here regarding getting the XML Attribute of my xml file, here is a snippet:
<music_songs>
<song>
<title>(I Just) Died In Your Arms</title>
<date added="03-24-2009" />
</song>
</music_songs>
Here is my code,
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.XML" %>
<script runat="server">
Sub Page_Load()
Dim file As String = Context.Server.MapPath("alice_music_list2.xml")
Dim document As XmlDocument = New XmlDocument()
document.Load(file)
Dim songList As XmlNodeList
songList = document.SelectNodes("/music_songs/song/category[text()='Rock']")
Dim song As XmlNode
For Each song In songList
Dim title As XmlNode = song.FirstChild
songNodesOut.Text &= "<b>Title:</b> " & title.InnerText & "<br/>"
Dim date AS XmlNode = title.NextSibling
Dim dateAttribute AS attribute= date.Attributes.GetNamedItem("added").Value
SongNodesOut.Text &= "<b>Date Added to Collection</b> " & dateAttribute & "<br/><hr/><br />"
Next
}
end Sub
</script>
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30183: Keyword is not valid as an identifier.
Source Error:
Line 27: Dim date AS XmlNode = title.NextSibling
Line 28: Dim dateAttribute AS attribute= date.Attributes.GetNamedItem("added").Value
Line 29: SongNodesOut.Text &= "<b>Date Added to Collection</b> " & dateAttribute & "<br/><hr/><br />"
Is this not the way for me to declare attributes?
Thanks for your help.