I have problem with equal by field ID in xml file and put this data to datagridview in c#. I know how to do this in xslt, but i dont know how to use it in c#. Below is xml file source:
<MAGIC>
<DOCS>
<DOC>
<POS>
<CUSTOMER_ID>1</CUSTOMER_ID>
</POS>
</DOC>
</DOCS>
<CUSTOMERS>
<CUSTOMER>
<ID>1</ID>
<NAME>NAME1</NAME>
</CUSTOMER>
</CUSTOMERS>
</MAGIC>
My code to this xml file is like this:
XmlNodeList xnListPos = xml.SelectNodes("/MAGIC/DOCS/DOC/POS");
string id = "";
string nameOfCustomer = "";
foreach (XmlNode xnpos in xnListPos)
{
id = xnpos["CUSTOMER_ID"].InnerText;
nameOfCustomer = xml.SelectSingleNode("/MAGIC/CUSTOMERS/CUSTOMER[ID=id]/NAME");
dgv.Rows.Add(id, nameOfCustomer);
}
But I have a error System.Xml.XmlNode.SelectSingleNode(...) returned null. I don`t know how it works in c#. Maybe some one can help me.