示例#1
0
        public void ReplaceText(string find, string replace)
        {
            find = find.Replace("<", "&lt;");
            find = find.Replace(">", "&gt;");
            string xml = OuterXml.Replace(find, replace);

            if (xml != "")
            {
                LoadXml(xml);
            }
        }
示例#2
0
        private void SaveFile()
        {
            StreamWriter writer = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\" + FILE_NAME);
            string       xml    = OuterXml.Replace(@"\n", @"&#10;");

            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>&lt;StsUri vt=""8""&gt;https://&amp;lt;Namespace&amp;gt;-sb.accesscontrol.windows.net/&lt;/StsUri&gt;</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://&lt;Namespace&gt;-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);
        }