Wednesday, July 21, 2010

LINQ with XML

XDocument xmlDoc = XDocument.Load(@"D:\2202_BO_1.xml");
var ACKZIP = from objACKZIP in xmlDoc.Descendants("ACKZIP").Descendants("tbl_DTFileCounter")
select new
{
ShopCode = objACKZIP.Element("ShopCode").Value.Trim(),
ReceiveZipFileCounter = objACKZIP.Element("SendZipFileCounter").Value.Trim(),
ZipFileName = objACKZIP.Element("ZipFileName").Value.Trim(),
ZipFileStatus = objACKZIP.Element("ZipFileStatus").Value.Trim(),
};
foreach (var obj in ACKZIP)
{
MessageBox.Show(obj.ShopCode);
MessageBox.Show(obj.ReceiveZipFileCounter);
MessageBox.Show(obj.ZipFileName);
MessageBox.Show(obj.ZipFileStatus);
}

No comments:

Post a Comment