本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}