public static Regex XMLRegex = new Regex(@"<(?<field>[^/>]+)>(?<data>.*)</\k<field>>", RegexOptions.Compiled | RegexOptions.Singleline);and then
MatchCollection matches = XMLRegex.Matches(tcSQML); foreach (Match m in matches) { if (!tDictionary.ContainsKey(m.Groups["field"].ToString())) tDictionary.Add(m.Groups["field"].ToString(), m.Groups["data"].ToString().Trim()); }Unfortunately, we found a case where this pattern doesn't work, e.g.
<func>appendrecs</func><tcoperator>ADMIN</tcoperator> <tcrecorddata>CHARGEDATE0001902/28/2019 00:00:00SALE_TEXT 00429<func>PaymentPlanCharge</func><orig_amount>125</orig_amount>SALESPOINT00006DANAIITRANSTYPE 000010</tcrecorddata> <tcsalespoint>DANAII032001</tcsalespoint><tctablename>WW_SALES</tctablename>In other words, the tcRecordData contains SALE_TEXT which in turn contains some XML like text. We need to parse the above string properly into a few parameters, in particular, the FUNC parameter is supposed to be "AppendRecs" but with the code above it becomes a complex text ending with the last /func