diff --git a/MusicLyricApp/Utils/XmlUtils.cs b/MusicLyricApp/Utils/XmlUtils.cs index 032f4c9..786ce04 100644 --- a/MusicLyricApp/Utils/XmlUtils.cs +++ b/MusicLyricApp/Utils/XmlUtils.cs @@ -1,11 +1,15 @@ using System.Collections.Generic; -using System.Linq; +using System.Text.RegularExpressions; using System.Xml; namespace MusicLyricApp.Utils { public static class XmlUtils { + private static Regex _badAmpersand = new Regex("&(?![a-zA-Z]{2,6};|#[0-9]{2,4};)"); + + private static string _goodAmpersand = "&"; + /// /// 创建 XML DOM /// @@ -15,6 +19,9 @@ public static XmlDocument Create(string content) { content = RemoveIllegalContent(content); + // replace & symbol + content = _badAmpersand.Replace(content, _goodAmpersand); + var doc = new XmlDocument(); doc.LoadXml(content);