join 2 xml file using linq

Posted by Klbaiju under XML on 12/10/2009 | Views : 2640 | Status : [Member] | Replies : 1
i have 2 xml files. i want to display the common record in this 2 files
i want to display in agridview;
the following code displays record in a literal.
i want to display the result in a grid .
any possibility

K L BAIJU


XDocument xmldocemp = XDocument.Load(Server.MapPath("Employee.xml"));
XDocument xmldocdept = XDocument.Load(Server.MapPath("Dept.xml"));
var emps = from emp in xmldocemp.Descendants("Employee")
select emp;

var depts = from dept in xmldocdept.Descendants("Department")

select dept;

foreach (var xnodemp in emps)
{
foreach (var xnoddept in depts)
{
if (xnodemp.Element("Id").Value == xnoddept.Element("Id").Value)
{


Literal1.Text = Literal1.Text + "Name : " + xnoddept.Element("Name").Value + "<br/>";
Literal1.Text = Literal1.Text + "Dept : " + xnoddept.Element("Dept").Value + "<br/>";
}
}
}




Responses

Posted by: Vuyiswamb on: 12/11/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
This is what you are looking for

http://www.a2zdotnet.com/View.aspx?id=43


Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response