
Untitled
By: a guest on
May 27th, 2012 | syntax:
None | size: 0.83 KB | hits: 20 | expires: Never
Linq to XML: .Net Windows Forms, XML query
private void cboCustomer_SelectedIndexChanged(object sender, EventArgs e)
{
var doc = XElement.Load("Portfolio.xml");
customerId = cboCustomer.SelectedIndex.ToString();
if (cboCustomer.SelectedIndex != 0)
{
var custRecord =
from account in doc.Descendants("account")
let acct = account.Element("acct")
where (string)account.Element("custid") == customerId
select new
{Fname=(string)account.Element("fname"),
Lname = (string)account.Element("lname"),
Ssn = (string)account.Element("ssn"),
Dob = (string)account.Element("dob")
};
}
}
where acct.Attribute("custid").Value == customerId