Wrox Programmer Forums
|
BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9
This is the forum to discuss the Wrox book Professional ASP.NET 3.5: In C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470187579
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2009, 09:53 AM
Authorized User
 
Join Date: Jun 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to workidoo
Default 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
End
Class

I tryed to copy a code that I downloaded from Wrox, but it don't help.

Thx for you help!
__________________
http://www.workidoo.com
 
Old August 3rd, 2009, 11:31 AM
Authorized User
 
Join Date: Jun 2008
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to workidoo
Default I find it.

I forgot:

<XmlRoot(ElementName:=
"Author", _
Namespace:=
"http://example.books.com")> PublicClass Author
<XmlElement(ElementName:=
"first-name")> Public FirstName AsString
<XmlElement(ElementName:="last-name")> Public LastName AsString
__________________
http://www.workidoo.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent ::Reading two xml files subcontent and adding that to third xml file archleader XSLT 6 August 18th, 2009 03:11 AM
problem reading a value from an xml mrjoka XML 14 June 8th, 2007 10:48 AM
reading a XML file connect2sandep XML 1 December 14th, 2006 04:50 AM
reading a XML file connect2sandep General .NET 0 December 13th, 2006 02:10 PM
Reading XML evidica C# 0 July 25th, 2006 10:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.