I'm having a problem because I'm reading the tags from an NFe xml, but I'm not able to show in the columns of the datagridview, my code is reading the correct tags, but it does not see anything in the datagridview.
Follow the part of the xml I'm reading
-<det nItem="1">
-<prod>
<cProd>PA3003</cProd>
<cEAN/>
<xProd>OLEO ESSENCIAL DE CITRONELA</xProd>
<NCM>33012911</NCM>
<CEST>2000600</CEST>
<EXTIPI>00</EXTIPI>
<CFOP>5101</CFOP>
<uCom>KG</uCom>
<qCom>25.0000</qCom>
<vUnCom>123.900000000</vUnCom>
<vProd>3097.50</vProd>
<cEANTrib/>
<uTrib>KG</uTrib>
<qTrib>25.0000</qTrib>
<vUnTrib>123.900000000</vUnTrib>
<indTot>1</indTot>
<xPed>002497/1</xPed>
</prod>
follow my code
private void btn_xml_Click(object sender, EventArgs e)
{
string FileName = @"C:\Xml_Entrada53- CITROLEO.xml";
List<string> ListaItens = new List<string>();
XmlDocument doc = new XmlDocument();
doc.Load(FileName);
var proditens = doc.GetElementsByTagName("prod");
foreach (XmlElement nodo in proditens)
{
ListaItens.Add(nodo.GetElementsByTagName("cProd")[0].InnerText.Trim());
ListaItens.Add(nodo.GetElementsByTagName("xProd")[0].InnerText.Trim());
ListaItens.Add(nodo.GetElementsByTagName("qCom")[0].InnerText.Trim());
}
dgw_Xml.DataSource = ListaItens;
}
class ClasseItensXml
{
string CodigoProduto;
string NomeProduto;
string QtdProduto;
public string CodigoP
{
get { return CodigoProduto; }
set { CodigoProduto = value; }
}
public string NomeP
{
get { return NomeProduto; }
set { NomeProduto = value; }
}
public string QtdP
{
get { return QtdProduto; }
set { QtdProduto = value; }
}
}