コード例 #1
0
        public Object ParseXml(string xml)
        {
            XmlCamt053  xmlCamt053File = new XmlCamt053();
            XmlDocument xmlDocument    = new XmlDocument();
            string      parsedXml      = "";

            try
            {
                xmlDocument.LoadXml(xml);
                // var singleNode = xmlDocument.SelectSingleNode("BkToCstmrStmt/Ntry/NtryDtls/Btch/NbOfTxs");

                var ntrtyList = xmlDocument.GetElementsByTagName(XmlCamt053Constants.Ntry);
                for (int i = 0; i < ntrtyList.Count; i++)
                {
                    xmlCamt053File.Ntry.Add(
                        this.FillNtryFromXml(ntrtyList.Item(i))
                        );

                    parsedXml += xmlCamt053File.Ntry[i].ToString() + @"\r\n";                     // This can be a json serializer or parser
                }
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.ToString());
            }
            return(parsedXml);
        }
コード例 #2
0
        public object ParseXml(string xml)
        {
            XmlCamt053 xmlCamt053 = new XmlCamt053();

            this.SetEntriesFromCamt(xmlCamt053, xml);

            Console.WriteLine($"{xmlCamt053.ToString()}");

            return(xmlCamt053);
        }
コード例 #3
0
        private string SetEntriesFromCamt(XmlCamt053 xmlCamt, string xml)
        {
            string ntryTagName = "Ntry";
            string beginTag    = $"<{ntryTagName}>";
            string endTag      = $"</{ntryTagName}>";

            string[] xmlTags   = xml.Split(@"<");
            string   xmlResult = "";
            bool     isMatch   = false;

            for (int i = 0; i < xmlTags.Length; i++)
            {
                if (Regex.IsMatch(@"<" + xmlTags[i], beginTag))
                {
                    isMatch = true;
                    i++;
                }
                if (Regex.IsMatch(@"<" + xmlTags[i], endTag))
                {
                    isMatch = false;
                    XmlCamt053Entry xmlCamt053Entry = this.CreateXmlCamt053Entry(xmlResult);

                    // xmlCamt.Ntry.Add(xmlCamt053Entry.NtryRef, xmlCamt053Entry);
                }

                if (isMatch)
                {
                    xmlResult += $"<{xmlTags[i]}";
                }
                if (!isMatch)
                {
                    xmlResult = string.Empty;
                }
            }
            return("");
        }