Click or drag to resize
XmlExtensionsAddChildElements Method
Adds the collection of values into the XML element, each value as a nested element. Ensures the alphabetic order of the values in the element.

Namespace: CMS.Helpers
Assembly: CMS.Helpers (in CMS.Helpers.dll) Version: 13.0.131
Syntax
C#
public static void AddChildElements(
	this XmlElement node,
	IDictionary values,
	string elementName = null,
	Action<XmlElement, string, Object> transform = null,
	bool removeEmptyEntries = true
)

Parameters

node
Type: System.XmlXmlElement
Parent XML element.
values
Type: System.CollectionsIDictionary
Collection of element values.
elementName (Optional)
Type: SystemString
If set, the elements are added with the given name and the key is stored in attribute name. Key is used for the element name otherwise.
transform (Optional)
Type: SystemActionXmlElement, String, Object
Function allowing to modify the added element that has three parameters - XML element to modify, string key and value from the collection values.
removeEmptyEntries (Optional)
Type: SystemBoolean
If true, only elements with non-empty value are added to the parent element node.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type XmlElement. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentExceptionelementName was not supplied and some keys of values are an empty string.
ArgumentNullExceptionnode is null.
InvalidOperationExceptionKeys of values cannot be ordered or node is missing owner document.
XmlExceptionelementName was not supplied and some keys of values contain characters not suitable for an XML element name.
See Also