NFe.ConvertTxt.nfeRead.ReadFromString C# (CSharp) Method

ReadFromString() public method

public ReadFromString ( string xmlString ) : void
xmlString string
return void
        public void ReadFromString(string xmlString)
        {
            doc = new XmlDocument();
            try
            {
                doc.LoadXml(xmlString);
                this.XmlNota = doc.OuterXml;

                foreach (XmlNode nodeRoot in doc.ChildNodes)
                {
                    if (nodeRoot.LocalName.Equals("NFe"))
                    {
                        processaNFe(nodeRoot);
                    }
                    if (nodeRoot.LocalName.Equals("nfeProc"))
                    {
                        foreach (XmlNode nodenfeProc in nodeRoot.ChildNodes)
                        {
                            switch (nodenfeProc.LocalName.ToLower())
                            {
                                case "nfe":
                                    processaNFe(nodenfeProc);
                                    break;

                                case "protnfe":
                                    processaProtNfe(nodenfeProc);
                                    break;
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(nfe.ide.dhEmi) && nfe.infNFe.Versao < 3)
                    throw new Exception("Arquivo não é de nota fiscal NF-e");

                if (string.IsNullOrEmpty(nfe.ide.dhEmi) && nfe.infNFe.Versao >= 3)
                    if (nfe.ide.mod == TpcnMod.modNFCe)
                        throw new Exception("Arquivo não é de nota fiscal NFC-e");
                    else
                        throw new Exception("Arquivo não é de nota fiscal NF-e");
            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally
            {
                doc = null;
            }
        }