Reading author instances via LINQ to XML Listing10-10q
Hello,
I am getting following error when I am trying to run Listing 10-10q
BC30002: Type Author has not been defined.
Row 17: Dim authors = From book In booksXML...<books:book> Select New Author _
Row 18: With {.FirstName = book.<books:author>.<books:first-name>.Value, _
Row 19: .LastName = book.<books:author>.<books:last-name>.Value}
This is how my code behind looks like
Imports System
Imports System.Xml
Imports System.Linq
Imports System.Xml.Linq
Imports<xmlns:books="http://example.books.com">
PartialClass Chapter10_ReadingauthorinstancesviaLINQtoXML
Inherits System.Web.UI.Page
ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs) _
HandlesMe.Load
Dim booksXML = XDocument.Load(Server.MapPath("books.xml"))
Dim authors = From book In booksXML...<books:book>SelectNew Author _
With {.FirstName = book.<books:author>.<books:first-name>.Value, _
.LastName = book.<books:author>.<books:last-name>.Value}
ForEach a As Author In authors
Response.Write(String.Format("Author: {1}, {0}<BR/>", a.FirstName, a.LastName))
Next
EndSub
EndClass
I tryed to copy a code that I downloaded from Wrox, but it don't help.
Thx for you help!
__________________
http://www.workidoo.com
|