Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 3rd, 2009, 09:53 AM
Authorized User
 
Join Date: Jun 2008
Location: , , .
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
  #2 (permalink)  
Old August 3rd, 2009, 11:31 AM
Authorized User
 
Join Date: Jun 2008
Location: , , .
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:45 PM.


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