Class XmlHelper
Class providing xml validation methods.
public static class XmlHelper
- Inheritance
-
objectXmlHelper
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
objectValue to convert.
type
TypeType 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
XmlNodeNode representing a form field
attributeName
stringAttribute 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
XmlNodeNode representing a form field
attributeName
stringAttribute name
defaultValue
stringDefault 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
XmlAttributeXml attribute to get value of
defValue
stringDefault 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
XmlAttributeCollectionNode 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
XmlNodeXml node
attributes
string[,]Array of attributes (0 - name, 1 - value]) to set
insertEmpty
boolIndicates 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
stringInput text to encode
Returns
- string
XmlAttributeIsEmpty(XmlAttribute)
Determines whether specified xml attribute is defined.
public static bool XmlAttributeIsEmpty(XmlAttribute attribute)
Parameters
attribute
XmlAttributeXml attribute to check
Returns
- bool