本文整理匯總了C#中System.Xml.XmlDocument.AddRootNode方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument.AddRootNode方法的具體用法?C# XmlDocument.AddRootNode怎麽用?C# XmlDocument.AddRootNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.AddRootNode方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Should_add_root_node
public void Should_add_root_node()
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode rootNode = xmlDoc.AddRootNode("root");
Check.That(xmlDoc.ChildNodes[1]).IsEqualTo(rootNode);
Check.That(xmlDoc.ChildNodes[1].Name).IsEqualTo(rootNode.Name);
}
示例2: SaveFile
/// <summary>
///
/// </summary>
/// <param name="fileName"></param>
public static bool SaveFile(string fileName)
{
const int version = 1;
try
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode rootNode = xmlDoc.AddRootNode("FlowSimulator");
rootNode.AddAttribute("version", version.ToString());
FlowGraphManager.Instance.Save(rootNode);
NamedVariableManager.Instance.Save(rootNode);
xmlDoc.Save(fileName);
LogManager.Instance.WriteLine(LogVerbosity.Info, "'{0}' successfully saved", fileName);
}
catch (System.Exception ex)
{
LogManager.Instance.WriteException(ex);
return false;
}
return true;
}
示例3: Should_add_attribute_to_node
public void Should_add_attribute_to_node()
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode rootNode = xmlDoc.AddRootNode("root");
rootNode.AddAttribute("attribute", "value");
Check.That(rootNode.Attributes["attribute"].Value).IsEqualTo("value");
}
示例4: Should_add_node_text
public void Should_add_node_text()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.AddRootNode("root");
XmlElement nodeTxt = xmlDoc.CreateElementWithText("Text", "value");
Check.That(nodeTxt.Name).IsEqualTo("Text");
Check.That(nodeTxt.InnerText).IsEqualTo("value");
}
示例5: SaveSettings
/// <summary>
///
/// </summary>
private void SaveSettings()
{
var serializer = new XmlLayoutSerializer(dockingManager1);
using (var stream = new StreamWriter(m_DockSettingsFile))
{
serializer.Serialize(stream);
}
XmlDocument xmlDoc = new XmlDocument();
XmlNode rootNode = xmlDoc.AddRootNode("FlowSimulator");
rootNode.AddAttribute("version", "1");
XmlNode winNode = xmlDoc.CreateElement("Window");
rootNode.AppendChild(winNode);
winNode.AddAttribute("version", "1");
if (WindowState == WindowState.Minimized)
{
winNode.AddAttribute("windowState", Enum.GetName(typeof(WindowState), WindowState.Normal));
winNode.AddAttribute("left", m_LastLeft.ToString());
winNode.AddAttribute("top", m_LastTop.ToString());
winNode.AddAttribute("width", m_LastWidth.ToString());
winNode.AddAttribute("height", m_LastHeight.ToString());
}
else
{
winNode.AddAttribute("windowState", Enum.GetName(typeof(WindowState), WindowState));
winNode.AddAttribute("left", Left.ToString());
winNode.AddAttribute("top", Top.ToString());
winNode.AddAttribute("width", Width.ToString());
winNode.AddAttribute("height", Height.ToString());
}
// m_SessionControl.SaveSettings(rootNode);
// m_MessageControl.SaveSettings(rootNode);
// m_TaskControl.SaveSettings(rootNode);
// m_ReportControl.SaveSettings(rootNode);
// m_LogControl.SaveSettings(rootNode);
// m_ScriptControl.SaveSettings(rootNode);
xmlDoc.Save(m_UserSettingsFile);
}