public void ReplaceText(string find, string replace) { find = find.Replace("<", "<"); find = find.Replace(">", ">"); string xml = OuterXml.Replace(find, replace); if (xml != "") { LoadXml(xml); } }
private void SaveFile() { StreamWriter writer = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\" + FILE_NAME); string xml = OuterXml.Replace(@"\n", @" "); if (!xml.Contains(@"<?mso-application progid=""Word.Document""?>")) { xml = @"<?mso-application progid=""Word.Document""?>" + xml; } if (!xml.Contains(@"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>")) { xml = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>" + xml; } writer.Write(xml); writer.Close(); }
public void UnescapeXmlTreeWithAngularBracketsInText() { const string xml = @"<TransportTypeData><StsUri vt=""8"">https://&lt;Namespace&gt;-sb.accesscontrol.windows.net/</StsUri></TransportTypeData>"; var document = new XmlDocument(); document.LoadXml(xml); var sutMock = new Mock <ExpandApplicationBinding> { CallBase = true }; sutMock.Setup(m => m.WriteWarning(It.IsAny <string>())); sutMock.Object.UnescapeXmlTree(document.DocumentElement); document.DocumentElement !.OuterXml .Should().Be("<TransportTypeData><StsUri vt=\"8\">https://<Namespace>-sb.accesscontrol.windows.net/</StsUri></TransportTypeData>"); document.DocumentElement !.FirstChild.InnerText .Should().Be("https://<Namespace>-sb.accesscontrol.windows.net/"); sutMock.Verify(m => m.WriteWarning(It.IsAny <string>()), Times.Never); }