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


C# XmlDocument.WithRoot方法代碼示例

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


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

示例1: Write

        public XmlDocument Write(Test test)
        {
            var document = new XmlDocument();

            var node = new TestXmlNode(document.WithRoot("Test"));
            new WriterVisitor(test, node).Write();

            return document;
        }
開發者ID:adymitruk,項目名稱:storyteller,代碼行數:9,代碼來源:TestWriter.cs

示例2: Write

        public static void Write(SettingsData data, string filename)
        {
            var document = new XmlDocument();
            var root = document.WithRoot("Settings");
            root.SetAttribute("category", data.Category.ToString());

            data.AllKeys.Each(
                key => { root.AddElement("add").WithAtt("key", key).WithAtt("value", data[key].ToString()); });

            document.Save(filename);
        }
開發者ID:NTCoding,項目名稱:FubuRaven.NTCoding.com,代碼行數:11,代碼來源:XmlSettingsParser.cs

示例3: WriteSpecRoot

        public static XmlElement WriteSpecRoot(Specification specification, XmlDocument document)
        {
            var root = document.WithRoot(Spec);
            root.SetAttribute(Id, specification.id);
            root.SetAttribute(MaxRetries, specification.MaxRetries.ToString());
            root.SetAttribute(TagsAtt, specification.Tags.Join(", "));
            root.SetAttribute(LifecycleAtt, specification.Lifecycle.ToString());
            root.SetAttribute(Name, specification.name);

            return root;
        }
開發者ID:aabenoja,項目名稱:Storyteller,代碼行數:11,代碼來源:XmlWriter.cs

示例4: XmlFromFileWithRoot

        public static XmlDocument XmlFromFileWithRoot(this string fileName, string root)
        {
            if (File.Exists(fileName))
            {
                return new XmlDocument().FromFile(fileName);
            }

            var document = new XmlDocument();
            document.WithRoot(root);

            return document;
        }
開發者ID:storyteller,項目名稱:Storyteller,代碼行數:12,代碼來源:XmlExtensions.cs

示例5: XmlMediaDocument

        public XmlMediaDocument(XmlMediaOptions options)
        {
            _document = new XmlDocument();
            if (options.Namespace.IsEmpty())
            {
                _document.WithRoot(options.Root);
            }
            else
            {
                var node = _document.CreateNode(XmlNodeType.Element, options.Root, options.Namespace);
                _document.AppendChild(node);
            }

            _topNode = options.NodeStyle == XmlNodeStyle.AttributeCentric
                           ? (IXmlMediaNode) new XmlAttCentricMediaNode(_document.DocumentElement)
                           : new XmlNodeCentricMediaNode(_document.DocumentElement);

            _topNode.LinkWriter = options.LinkWriter;

            _options = options;
        }
開發者ID:jemacom,項目名稱:fubumvc,代碼行數:21,代碼來源:XmlMediaDocument.cs

示例6: write_stream

        public void write_stream()
        {
            var document = new XmlDocument();
            document.WithRoot("root");

            theRecordedOutput.Write("text/xml", document.Save);
            theRecordedOutput.Outputs.First().ShouldEqual(new SetContentType("text/xml"));

            var writeStream = theRecordedOutput.Outputs.Last().ShouldBeOfType<WriteStream>();

            writeStream.ReadAll().ShouldEqual(document.OuterXml);
        }
開發者ID:NeilSorensen,項目名稱:fubumvc,代碼行數:12,代碼來源:RecordedOutputTester.cs

示例7: write_stream

        public void write_stream()
        {
            var document = new XmlDocument();
            document.WithRoot("root");

            theRecordedOutput.Write("text/xml", stream =>
            {
                document.Save(stream);
                return Task.CompletedTask;
            });

            theRecordedOutput.Outputs.First().ShouldBe(new SetContentType("text/xml"));

            var writeStream = theRecordedOutput.Outputs.Last().ShouldBeOfType<WriteStream>();

            writeStream.ReadAll().ShouldBe(document.OuterXml);
        }
開發者ID:DarthFubuMVC,項目名稱:fubumvc,代碼行數:17,代碼來源:RecordedOutputTester.cs


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