本文整理匯總了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);
}