One more easiest way to create XSD from XML :)

 

Hello friends,

as i have shared earlier in my previous post  https://indiandotnet.wordpress.com/2013/07/17/how-to-generate-xsd-from-xml-in-2-minutes/ .

To make it more easy visual studio provide you a best utility which i want to share here

see below screenshot .

When you open XML in the visual studio in the menu you will get XML option. Just click on create Schema submenu and you are good to go.

wow you have XML schema. Isn’t it simple. 🙂

GenerateXSD

Enjoy friends 🙂

Thanks & Regards,

Rajat Jaiswal

How to generate XSD from XML in 2 minutes ?

Dear Friends,

Many times we require XSD from XML which we can utilize in our code. so to achieve this we need to run a simple command which will create your XML in XSD. Now you are thinking what is that command so here we go

you just need to write following command on command prompt

XSD.EXE  “YourXML file Name”  /outputdir:

Example

XSD.exe “d:\myxml.xml” /outputdir:

When you run it it will generate the XSD file in system32 folder.

I hope you like it.

Thanks & Regards,

Rajat Jaiswal

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

 

A new milestone 125th post on Indiandotnet.wordpress.com so far so good

Dear Friends,
This post is different post from my regular technical articles and it is my 125th post on Indiandotnet.wordpress.com.

I would like to thank all of my friends, family members, colleges & most valuable the reader of this blog who continuously giving feedback and improving my skill also.
So thank you very very much.
Keep reading, Keep commenting, and keep giving feedback.
I need more improvement and I know you people will help me in sharing my thoughts.
God bless you all.


Happy Holidays.


Merry Christmas.
Thanks
Rajat Jaiswal

Pivot Viewer Example ” Cricket World Cup 2011″

Hello friends,
We have left the last topic with definition of Pivot Viewer now in this post we are going to make a sample which use pivot viewer. Our sample is “Cricket World Cup 2011” so here we go
Step 1:- First checks on your machine following things are installed if not then please installed them
a) Silverlight 4 (http://silverlight.codeplex.com/ )
b) Pivot collection tool (http://www.silverlight.net/learn/pivotviewer/collection-tools/)
Step 2:- Once you have installed above tools then create a pivot collection first. The pivot collection can also be generate using code also (at run time) but here I am using excel pivot collection generator.
Step 3:- For generating collection just open excel book go to pivot collection menu when you click pivot collection just below the menu new pivot collection tools will be visible. Then just create new collection button as shown in above image.

Excel Pivot Collection

Step 4:- When you click the new collection button you will get new excel object as shown in below fig

Pivot Collection Template

Step 5:- Now add the data according to your need as I added following columns
a) Team
b) Name
c) Bating Style
d) Bowling style
e) Is Captain
f) 100’s
g) 50’s
h) Runs
i) Average
j) URL
k) Description
l) Image
Step 6: Just fill the data as per the filtration column as shown in below fig

Cricket World Cup 2011 Player List
Step 7: Now once your data is fill then just click on publish collection button on toolbar
It will generate a “CXML” file which is collection Xml file with   deep zoom images collection.

Step8:- Now your collection is ready so next thing is how to use it. So first create a VS2010 Silverlight web application project.


Step 9: Copy CXML & and images folder to your web project first
Step 10: Once you copied the CXML and Images then open your Silverlight project and drag drop Pivot control or if it is not exist in your tool manually add for that just add reference as shown below.

xmlns:pivot=”clr-namespace:System.Windows.Pivot;assembly=System.Windows.Pivot”

Step 11:- Now in the code behind just assign the collection URL to pivot control. (The URL nothing but the CXML URL which you already copied in your web project in step 9) as shown below.
this.pivot.LoadCollection(“http://localhost:54210/CricketWorldCup2011.cxml“, “”);

Step 12: Now run the project you will get following screen. On left side you will get filter criteria when you change that your data will also change in center.

Cricket World cup 2011 Team pivot
Cricket World Cup 2011 Pivot

Hope the steps will be helpful and you can download code from.

Excel Data Cricket World Cup Team 2011 Data

Solution of Pivot Viewer Download Solution
Thanks & Esteemed Regards
Rajat Jaiswal

Project List on which we will work in future

Dear Friends,

 Merry Christmas!

I Hope you are enjoying  the holidays.

 After seeing the market trend and requirements I am interested in making following projects which will help me and other friends to understand basic project development and use latest technologies with some productive output.

 In coming up sessions i am going to use this project topic and create sample with latest technologies like Silverlight, Windows phone 7, VS 2010 etc.

 So here we go

 1) College Management

 2) School Management

3) Job Portal

 4) Forums

5) Blog

6) Employee Management

7) Bug Tracker

8) Time Sheet

9) Address Book

10) Project Management

11) Survey engine

 12) Stock Manager

13) Property Broker

14) Shop Management

15) Matrimonial

 16) Social Networking

17) Hotel Management

 18) Inventory Management

19) Accounting

20) Transport Management

21) Hospital Management

22) Ecommerce

Etc are the project list on which I will work in future to enhance my knowledge with productive work.

I will share code base and case study also in future

Hope you like it Once again wish you Merry Christmas.

 Thanks

 Rajat Jaiswal



Some useful Terminology (acronyms)

Hello friends,
Cheers!
Here I am with some useful terminology and these acronyms are generally used now days in broad way take a look.
1) ESB : Enterprise Service Bus
2) POX : Plain OLD XML
3) REST: Representational State Transfer
4) SOAP: Simple Object Access Protocol
5) RIA : Rich Internet Application
6) XML : Extensible Markup Language
7) JASON: Java Script Object Notation
8) DOM : Document Object Modeling
9) XAML : Extensible Application Markup Language
10) LINQ : Language Integrated Query
11) RSS: Really Simple Syndication
12) WCF: Windows Communication Foundation
13) WF: Windows Foundation
14) WPF: Windows Presentation Foundation
15) AJAX: Asynchronous Java script and XML
16) XLST: Extensible Style Sheet Language Transformation
17) INDIGO: Code name of Microsoft windows Communication foundation Technology
18) OSLO: Code name of Microsoft Modeling Technology
19) SOA: Service Oriented Architecture
20) ORCAS: dot net 3.5 Version called ORCAS
21) AVALON: code name of Microsoft Windows Presentation foundation Technology
22) Azure: Microsoft new Operation system Related to Cloud computing
23) Astoria : Code name of Ado.net Data services

I hope you people like it.
Enjoy life with dot net.

Your host
Rajat Jaiswal

How to read Resource files in our code by LINQ to XML ?

Hello friends,

Sorry for such a late post. Currently I am busy in too many works so not getting enough time to talk with you.

Today I am posting an interesting work which is how to read a resource file in our code with the help of LINQ TO SQL.

I can say only one thing which is its simple and easy to use. Just copy paste below code and you will get what to want.

Before code I will explain you that resource file is just like xml which has attributes and value and that particular attributes is your key.

 

Now we need to fetch value for particular key for a file for this you have to write below code. Where bv_strFileName is your resource file name and bv_strKey is key for which you need value.

Public Shared Function pub_LangaugeValue(ByVal bv_strFile As String, ByVal bv_strKey As String) As String

Try

Dim strValue As String = “”

Dim resxXML As New XDocument

resxXML = XDocument.Load(bv_strFile)

Dim a = From data In resxXML.Root.Descendants(“data”) _

Where data.Attribute(“name”).Value = bv_strKey _

Select New With {.resxA = data.Attribute(“name”).Value, .ResxValue = data.Element(“value”).Value}

If a.Count() > 0 Then

strValue = a.FirstOrDefault().ResxValue.ToString()

Else

strValue = bv_strKey

End If

Return strValue

Catch ex As Exception

Throw ex

End Try

End Function ‘pub_LangaugeValue

 

Where bv_strFileName is full path name of our resource file and bv_strkey is the key for which we need to find the value.

Below is example how to use it our aspx.

Suppose we want to read LabelResource1.text value in Spanish whose file name is home.aspx.es.resx.

 

Then we have to call the above function like below.

Response.write(pub_LanguageValue(server.mapPath(“/App_LocalResources/home.aspx.es.resx”),”LabelResource1.text”)

With the help of above code.

We can get key’s value from different resource file.

 

Thanks

Rajat Jaiswal

LINQ tutorial Part -IV

. Linq To XML (Add ,edit ,delete ): –

 

One of the intresting topic is xml. As a programmer I am not using XML in my daily use but I like XML.

Today I just wondering to take a suitable example which will do add,edit & delete with LINQ. So first we have to Create a xml file for that lets we created a xml file with following format.

<?xml version=1.0 encoding=utf-8?>
<Trainings>
<Training>
<Id>2</Id>
<Person>RAJAT JAISWAL</Person>
<FrameWork>2</FrameWork>
<ASPNET>2</ASPNET>
<Communication>4</Communication>
<HTML>5</HTML>
<LogicBuilding>4</LogicBuilding>
<SqlServer>5</SqlServer>
<Remark>testing</Remark>
</Training>
</Trainings>
Now if we want to add new record in this xml file then our first moto is to read the xml using linq . For this we first use a import statement

Imports System.Xml.Linq by this we are able to use Linq over xml.

Now for reading we just do same as we do for database read (linq to sql ) but before that we have to create the object of xdocument from where the data will be fatch. As shown below

Dim TrainXDoc As XDocument = XDocument.Load(Server.MapPath(“MyTraining.xml”))

What this statement does it create same object like dataContext in sql.

And below is linq over this document and the Descendants(“Training”) like table or other object like storeprocedure in dbContext.

Dim lnqTraining = From myTraining In TrainXDoc.Descendants(“Training”) _

Select New With {.Id = myTraining.Element(“Id”).Value, _

.Person = myTraining.Element(“Person”).Value, _

.FrameWork = myTraining.Element(“FrameWork”).Value, _

.ASPNET = myTraining.Element(“ASPNET”).Value, _

.SqlServer = myTraining.Element(“SqlServer”).Value, _

.LogicBuilding = myTraining.Element(“LogicBuilding”).Value, _

.HTML = myTraining.Element(“HTML”).Value, _

.Communication = myTraining.Element(“Communication”).Value, _

.Remark = myTraining.Element(“Remark”).Value}

In the above elements like a row in datatable and we access there column using the tag name like Id, Person,Framework.

Now our second moto is to Add & Update the Add a new record can be done as follows

TrainXDoc .Element(“Trainings”).Add(New XElement(“Training”, New XElement(“Id”, lngId), New XElement(“Person”, Me.txtName.Text.Trim), _

New XElement(“FrameWork”, ddlFramWork.SelectedValue), New XElement(“ASPNET”, ddlAspNet.SelectedValue), _

New XElement(“Communication”, ddlCommunication.SelectedValue), New XElement(“HTML”, Me.ddlHtml.SelectedValue), _

New XElement(“LogicBuilding”, Me.ddlLogicBuilding.SelectedValue), New XElement(“SqlServer”, Me.ddlSqlServer.SelectedValue), _

New XElement(“Remark”, Me.txtRemark.Text.Trim)))

Here it added new record in traindoc’s trainings element which was root element.

After this we use MyTrainXDoc.Save(Server.MapPath(“MyTraining.xml”)) which save in the file.

For update we just find the node using the linq which we want to update then made changes in the particular node elements. And call save method as above.

For delete just find the element from linq then remove like xRoot.Remove() then save the xdoc.

For more detail just download the code from

 

http://www.indiandotnet.tk/

Thanks & Regards

Rajat Jaiswal