Пример #1
0
        public static Comprobante ObtenerComprobantes(String direccionFisica)
        {
            Comprobante comprobante = new Comprobante();

            try
            {
                XElement xelement = XElement.Load(direccionFisica);
                IEnumerable <XElement> elementos = xelement.Elements();
                String esSub;
                foreach (XElement Emisor in elementos)
                {
                    String esEmi;
                    esEmi = Emisor.Name.ToString();
                    if (esEmi.Contains("Emisor"))
                    {
                        comprobante.RFC = Emisor.Attribute("rfc").Value;
                    }
                    else if (esEmi.Contains("Receptor"))
                    {
                        comprobante.RFCRECEPTOR = Emisor.Attribute("rfc").Value;
                    }
                    else if (esEmi.Contains("Complemento"))
                    {
                        IEnumerable <XElement> subelem = Emisor.Elements();
                        foreach (XElement subElemento in subelem)
                        {
                            esSub = subElemento.Name.ToString();
                            if (esSub.Contains("TimbreFiscalDigital"))
                            {
                                comprobante.UUID = subElemento.Attribute("UUID").Value;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("ERROR: No se pudo leer el XML: " + direccionFisica);
            }

            return(comprobante);
        }