C#C
C#3y ago
Lucho

Can someone explain to me how this works

 public bool EliminarClienteXML(BE_Cliente cliente)
        {
            acceso = new DatosXML();
            XDocument docxml = acceso.LeerXML("Clientes.xml");

            XElement elemento = docxml.Descendants("Cliente").FirstOrDefault(x => Convert.ToInt32(x.Element("DNI").Value) == cliente.dni);

            elemento.Remove();
            docxml.Save("Clientes.xml");
            return true;
        }


I dont understand how this line works:
XElement elemento = docxml.Descendants("Cliente").FirstOrDefault(x => Convert.ToInt32(x.Element("DNI").Value) == cliente.dni);


This is how the xml file looks like:
<?xml version="1.0" encoding="utf-8"?>
<Clientes>
  <Cliente>
    <Nombre>Martin</Nombre>
    <Apellido>Rodriguez</Apellido>
    <DNI>45868900</DNI>
  </Cliente>
</Clientes>
Was this page helpful?