Table of Contents

Class XmlHelper

Namespace
CMS.Helpers
Assembly
CMS.Helpers.dll

Class providing xml validation methods.

public static class XmlHelper
Inheritance
object
XmlHelper

Methods

ConvertToString(object, Type)

Uses System.Xml.XmlConvert to convert these value types: System.DateTime, double, decimal, float, int, long, System.Guid, bool to their string representation. If value is of other type, returns result of its ToString() method.

public static string ConvertToString(object value, Type type)

Parameters

value object

Value to convert.

type Type

Type of the value.

Returns

string

GetAttributeValue(XmlNode, string)

Returns value of the specified attribute from the given node representing a form field.

public static string GetAttributeValue(XmlNode node, string attributeName)

Parameters

node XmlNode

Node representing a form field

attributeName string

Attribute name

Returns

string

GetAttributeValue(XmlNode, string, string)

Returns value of the specified attribute from the given node representing a form field.

public static string GetAttributeValue(XmlNode node, string attributeName, string defaultValue)

Parameters

node XmlNode

Node representing a form field

attributeName string

Attribute name

defaultValue string

Default value returned when attribute is not found

Returns

string

GetXmlAttributeValue(XmlAttribute, string)

Returns string value of the specified xml attribute.

public static string GetXmlAttributeValue(XmlAttribute attribute, string defValue)

Parameters

attribute XmlAttribute

Xml attribute to get value of

defValue string

Default value if xml attribute is not defined

Returns

string

GetXmlAttributes(XmlAttributeCollection)

Returns attributes as an array (0 - attribute name, 1 - value).

public static string[,] GetXmlAttributes(XmlAttributeCollection attribute)

Parameters

attribute XmlAttributeCollection

Node attributes collection

Returns

string[,]

SetXmlNodeAttributes(XmlNode, string[,], bool)

Sets (updates or inserts) xml attributes to specified xml node.

public static void SetXmlNodeAttributes(XmlNode node, string[,] attributes, bool insertEmpty = true)

Parameters

node XmlNode

Xml node

attributes string[,]

Array of attributes (0 - name, 1 - value]) to set

insertEmpty bool

Indicates whether attributes with value "" (empty string) should be inserted to the XML

XMLEncode(string)

XML encoding function.

public static string XMLEncode(string inputText)

Parameters

inputText string

Input text to encode

Returns

string

XmlAttributeIsEmpty(XmlAttribute)

Determines whether specified xml attribute is defined.

public static bool XmlAttributeIsEmpty(XmlAttribute attribute)

Parameters

attribute XmlAttribute

Xml attribute to check

Returns

bool