Book detail by ISBN number using ASP.NET

Dear Friends,
I am explaining basic steps by which you can get book detail from ISBN using ASP.NET

I am using 3 providers which have this database catalog and provide such facility.
So below is the list
1)    isbndb.com
2)    worldcat.org
3)    Google book API
So let us start with ISBNDB.com first. So to use this service you have to create first access key.


We can get access key by registration at ISBNDB.com and it is free.
Now when you have access key then you can play with the URL which is responsible for providing the book detail response as shown below http://isbndb.com/api/books.xml?access_key=xyz&index1=ISBN&value=012343

The response of the above URL is XML.
To achieve this I did have created a constant for above URL as shown below

Private Const ISBNAPIURL As String =”http://isbndb.com/api/books.xml?access_key=”

Now on asp.net web page I have used a textbox for ISBN number and a button for search

So on click of button search event we did following code

If Me.txtISBN.Text <> String.Empty Then
Dim requestURL As String
Step1: created  request url at run time to fetch ISBN number
requestURL = ISBNAPIURL + Common.GetISBNConfig().ToString() + “&index1=isbn&value1=” + Me.txtISBN.Text.ToString()

‘step2: now as the return type is fixed XML format I have provided the response to XDocument
Dim xDoc As XDocument = XDocument.Load(requestURL)

‘Step 3:- On the avbove XDoc I have applied LINQ to XML and as we know the XML node will have following book elements so we have used it.

Dim resultSet = From book In xDoc.Descendants(“BookData”)
Select New BookDetail() With {.BookTitle = book.Element(“Title”).Value,
.BookAuthor = book.Element(“AuthorsText”).Value,
.BookPublisher = book.Element(“PublisherText”).Value}

Step4 : now we check whether the result set have something or not and  If we found  entry then we assign the output to project.

If resultSet Is Nothing = False AndAlso resultSet.Count() > 0 Then
Me.lblBookName.Text = resultSet.FirstOrDefault().BookTitle.ToString()
Me.lblAuthor.Text = resultSet.FirstOrDefault().BookAuthor.ToString()
Me.lblPublisher.Text = resultSet.FirstOrDefault().BookPublisher.ToString()
Else
Me.lblMessage.Text = “Sorry ISBN Number not found, Please try different number.”
End If
Else
Me.lblMessage.Text = “Please enter the ISBN number”
End If

In this way you can get book detail by ISBN using asp.net LINQ to XML feature.

In the next tutorial we  will use wordcat api to access book information using ASP.NET.

Thanks & Best Regards,

Rajat Jaiswal

 

Advertisements

2 thoughts on “Book detail by ISBN number using ASP.NET

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s