Here's my code:
Dim strURLSearch As String
strURLSearch = "http://isbndb.com/api/books.xml"
strURLSearch = strURLSearch & "?access_key=CYGCL3GT"
strURLSearch = strURLSearch & "&index1=isbn&value1=" & Me.txtISBN.Text
Dim xResults As XElement = XElement.Load(strURLSearch)
Dim books = From BookData In xResults.Descendants("BookData") Select Title = BookData.Element("Title").Value, Author = BookData.Element("AuthorText").Value, Publisher = BookData.Element("PublisherText").Value
For Each BookData In books
Me.txtResults.Text = Me.txtResults.Text & BookData.Author & vbCrLf
Next
On the For Each loop, I'm getting a NullReferenceException error
Loading
Scott LyslePosted Jan 20, 2009, 3:30 AM
Replace your Selects with Lets:
Dim strURLSearch As String
strURLSearch = "http://isbndb.com/api/books.xml"
strURLSearch = strURLSearch & "?access_key=CYGCL3GT"
strURLSearch = strURLSearch & "&index1=isbn&value1=" & Me.txtISBN.Text
Dim xResults As XElement = XElement.Load(strURLSearch)
Dim books = From BookData In xResults.Descendants("BookData") Let Title = BookData.Element("TitleLong").Value Let Author = BookData.Element("AuthorsText").Value Let Publisher = BookData.Element("PublisherText").Value
For Each BookData In books
Me.txtResults.Text = Me.txtResults.Text & BookData.Author & vbCrLf
Next