- Timestamp:
- 04/21/09 15:27:35 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/Primitive/String2XmlFormatter.cs
r1570 r1615 3 3 using HeuristicLab.Persistence.Interfaces; 4 4 using System.Text; 5 using System.Text.RegularExpressions; 5 6 6 7 … … 10 11 public class String2XmlFormatter : FormatterBase<string, XmlString> { 11 12 12 public override XmlString Format(string s) { 13 public override XmlString Format(string s) { 13 14 StringBuilder sb = new StringBuilder(); 14 15 sb.Append("<![CDATA["); … … 18 19 } 19 20 20 private static readonly string[] separators = new string[] { "<![CDATA[", "]]>" }; 21 22 public override string Parse(XmlString x) { 21 public override string Parse(XmlString x) { 23 22 StringBuilder sb = new StringBuilder(); 24 foreach (string s in x.Data.Split(separators,25 StringSplitOptions.RemoveEmptyEntries)) {26 sb.Append( s);23 Regex re = new Regex(@"<!\[CDATA\[((?:[^]]|\](?!\]>))*)\]\]>", RegexOptions.Singleline); 24 foreach (Match m in re.Matches(x.Data)) { 25 sb.Append(m.Groups[1]); 27 26 } 28 27 return sb.ToString();
Note: See TracChangeset
for help on using the changeset viewer.