本文整理汇总了C#中System.Xml.XmlNode.AddElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.AddElement方法的具体用法?C# XmlNode.AddElement怎么用?C# XmlNode.AddElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.AddElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveTo
/// <summary>
/// Save the display settings to the specified XML node.
/// </summary>
/// <param name="display">XML node display settings should be added to.</param>
public void SaveTo(XmlNode display)
{
if(WindowState != FormWindowState.Normal)
display.AddElement("WindowState", (int)WindowState);
if(Location.X != -42 && Location.Y != -42)
display.AddElement("Location", string.Format("{0},{1}", Location.X, Location.Y));
if(Size.Width != -42 && Size.Height != -42)
display.AddElement("Size", string.Format("{0}x{1}", Size.Width, Size.Height));
}
示例2: GetNestedValue
/// <summary>
/// Gets a nested value.
/// </summary>
/// <param name="tokenValue">The nested token value.</param>
/// <param name="map">The field mapping.</param>
/// <param name="target">The target object to populate with mapped key/values.</param>
private void GetNestedValue(IEnumerable<object> tokenValue, MappedField map, XmlNode target)
{
XmlNode repeaterNode = target.AddElement(map.Target);
foreach (object row in tokenValue)
{
XmlNode rowNode = repeaterNode.AddElement(HttpResources.XmlRepeaterRowIdentifier);
var fields = row as NestedDictionary;
if (fields != null)
{
foreach (KeyValuePair<string, object> field in fields)
{
rowNode.AddElement(field.Key, field.Value.ToString());
}
}
else
{
rowNode.AddElement(row.ToString());
}
}
}