當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlNode.WriteContentTo方法代碼示例

本文整理匯總了C#中System.Xml.XmlNode.WriteContentTo方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlNode.WriteContentTo方法的具體用法?C# XmlNode.WriteContentTo怎麽用?C# XmlNode.WriteContentTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlNode的用法示例。


在下文中一共展示了XmlNode.WriteContentTo方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateHtml5StringFromXml

 /// <summary>
 /// Create a string that could be the contents of an HTML5 file and which corresponds to the specified DOM
 /// (presumed to contain appropriate content).
 /// This method has no business in this class except that it is so parallel to CreateHtml5FromXml that I wanted to keep them together.
 /// </summary>
 /// <param name="dom"></param>
 public static string CreateHtml5StringFromXml(XmlNode dom)
 {
     var output = new StringBuilder();
     using (var writer = XmlWriter.Create(output, GetXmlWriterSettingsForHtml5()))
     {
         dom.WriteContentTo(writer);
         writer.Close();
     }
     return CleanupHtml5(output.ToString());
 }
開發者ID:BloomBooks,項目名稱:BloomDesktop,代碼行數:16,代碼來源:TempFiles.cs

示例2: PrintNodeToConsole

 public static void PrintNodeToConsole(XmlNode node)
 {
     XmlWriterSettings settings = new XmlWriterSettings();
     settings.Indent = true;
     settings.ConformanceLevel = ConformanceLevel.Fragment;
     XmlWriter writer = XmlWriter.Create(Console.Out, settings);
     node.WriteContentTo(writer);
     writer.Flush();
     Console.WriteLine();
 }
開發者ID:BloomBooks,項目名稱:BloomDesktop,代碼行數:10,代碼來源:FluentAssertXml.cs

示例3: WriteNodeContentTo

			public void WriteNodeContentTo (XmlNode node)
			{
				node.WriteContentTo (output);
			}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:4,代碼來源:ecma2wiki.cs

示例4: WriteRawContent

 public void WriteRawContent(XmlNode node)
 {
     node.WriteContentTo(_xmlWriter);
 }
開發者ID:sergey-steinvil,項目名稱:xsddoc,代碼行數:4,代碼來源:MamlWriter.cs

示例5: GetIndentInnerXml

        public static string GetIndentInnerXml(XmlNode node)
        {
            MemoryStream m = new MemoryStream();

            XmlTextWriter w = new XmlTextWriter(m, Encoding.UTF8);
            w.Formatting = Formatting.Indented;
            w.Indentation = 4;
            node.WriteContentTo(w);
            w.Flush();

            m.Seek(0, SeekOrigin.Begin);

            StreamReader sr = new StreamReader(m, Encoding.UTF8);
            string strText = sr.ReadToEnd();
            sr.Close();

            w.Close();

            return strText;
        }
開發者ID:renyh1013,項目名稱:dp2weixin,代碼行數:20,代碼來源:DomUtil.cs

示例6: DeserializeObject

        static object DeserializeObject(IFormatter serializer, XmlNode element)
        {
            using (var memoryStream = new MemoryStream())
            using (var xmlDictionaryWriter = XmlDictionaryWriter.CreateTextWriter(memoryStream))
            {
                element.WriteContentTo(xmlDictionaryWriter);
                xmlDictionaryWriter.Flush();
                memoryStream.Position = 0;

                var deserializedObject = serializer.Deserialize(memoryStream);
                return deserializedObject;
            }
        }
開發者ID:bejubi,項目名稱:MmapMan,代碼行數:13,代碼來源:XmlWorkflowInstanceStore.cs

示例7: FormatXml

        public static string FormatXml(XmlNode node)
        {
            String Result = "";

            MemoryStream mStream = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(mStream, Encoding.Unicode);

            try
            {
                writer.Formatting = Formatting.Indented;

                // Write the XML into a formatting XmlTextWriter
                node.WriteContentTo(writer);
                writer.Flush();
                mStream.Flush();

                // Have to rewind the MemoryStream in order to read
                // its contents.
                mStream.Position = 0;

                // Read MemoryStream contents into a StreamReader.
                StreamReader sReader = new StreamReader(mStream);

                // Extract the text from the StreamReader.
                String FormattedXML = sReader.ReadToEnd();

                Result = FormattedXML;
            }
            catch (XmlException)
            {
                Result = node.InnerXml;
            }
            writer.Close();

            return Result;
        }
開發者ID:priestofpsi,項目名稱:theDiary-Common-Framework,代碼行數:36,代碼來源:Utility.cs

示例8: CreateHtm5FromXml

        public static TempFile CreateHtm5FromXml(XmlNode dom)
        {
            var temp = TempFile.TrackExisting(GetHtmlTempPath());

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.CheckCharacters = true;
            settings.OmitXmlDeclaration = true;//we're aiming at normal html5, here. Not xhtml.
            //CAN'T DO THIS: settings.OutputMethod = XmlOutputMethod.Html;

            using (var writer = XmlWriter.Create(temp.Path, settings))
            {
                dom.WriteContentTo(writer);
                writer.Close();
            }
            //now insert the non-xml-ish <!doctype html>
            File.WriteAllText(temp.Path, "<!DOCTYPE html>\r\n" + File.ReadAllText(temp.Path));

            return temp;
        }
開發者ID:JohnThomson,項目名稱:testBloom,代碼行數:20,代碼來源:TempFiles.cs


注:本文中的System.Xml.XmlNode.WriteContentTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。