Tuesday, August 26, 2008

LINQ to XML

LINQ --- Language Integrated Query
LINQ to Objects (to APIs)
LINQ to XML
LINQ to SQL (Relational database)

New namespace System.Xml.Linq includes a series of new LINQ to XML objects that make working with xml easier:

1) XDocument instead of XmlDocument

XDocument xdoc = XDocumnet.load(@"d:\HPCTO");

query xml:


XDocument xdoc = XDocument.Load(@"D:\HPCTO\Pavilio.xml");
var query = from ConfigGroup in xdoc.Descendants("ConfigGroup")
select new
{
ProductDescription = ConfigGroup.Attribute("Description").Value
};
foreach (var item in query)
{
Response.Write(item);
Response.Write("
");

No comments: