Example #1
0
        public static Afip GetAfipFromXml()
        {
            Afip af = null;

            if (File.Exists(XmlFileName))
            {
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreWhitespace = true;
                settings.IgnoreComments = true;

                XmlReader xmlIn = XmlReader.Create(XmlFileName, settings);

                if (xmlIn.ReadToDescendant("Afip"))
                {

                    af = new Afip();
                    xmlIn.ReadStartElement("Afip");

                    af.ImePrazanAfip = xmlIn.ReadElementContentAsString();
                    af.FolderAfip = xmlIn.ReadElementContentAsString();
                    af.ImeBilanci = xmlIn.ReadElementContentAsString();

                }

                xmlIn.Close();

            }

            return af;
        }
Example #2
0
        public static void SaveAfipToXml(Afip af)
        {
            if (af != null)
            {

                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;
                settings.IndentChars = "    ";

                XmlWriter xmlOut = XmlWriter.Create(XmlFileName, settings);

                xmlOut.WriteStartDocument();
                xmlOut.WriteStartElement("PodaciAfip");

                xmlOut.WriteStartElement("Afip");
                xmlOut.WriteElementString("ImePrazanAfip", af.ImePrazanAfip);
                xmlOut.WriteElementString("FolderAfip", af.FolderAfip);
                xmlOut.WriteElementString("ImeBilanci", af.ImeBilanci);
                xmlOut.WriteEndElement();

                xmlOut.WriteEndElement();

                xmlOut.Close();

            }
            else
            {
                if (File.Exists(XmlFileName))
                {
                    File.Delete(XmlFileName);
                }

            }
        }