Database Reference
In-Depth Information
Note
We have specified the
productstable.xml
file, which is located in a specific location on our machine;
you can use another XML file path based on your machine and XML file availability. The
productstable.xml
file is
also available with the source code for this chapter.
6.
Now, to set the LinqToSql form as the start-up form, open
Program.cs
in the
code editor, and modify the
Application.Run(new LinqToSql());
to appear as:
Application.Run(new LinqToXml());
.
Build solution, and then run the program by pressing Ctrl+F5; you should see
the results shown in Figure 18-10.
Figure 18-10.
Retrieving product details with LINQ to XML
How It Works
You specify the following statement using
XElement
of
System.Linq.Xml
to load the XML doc in memory.
XElement doc = XElement.Load(@"C:\VidyaVrat\C#2012 and SQL
2012\Chapter18\Code\Linq\productstable.xml ");