Class StringExtensions
- Namespace
- Cuemon.Extensions.Xml
- Assembly
- Cuemon.Extensions.Xml.dll
Extension methods for the String class.
public static class StringExtensions
- Inheritance
-
StringExtensions
Methods
EscapeXml(String)
Escapes the given XML value
.
public static string EscapeXml(this string value)
Parameters
Returns
- String
The input
value
with an escaped equivalent.
Exceptions
- ArgumentNullException
value
cannot be null.
SanitizeXmlElementName(String)
Sanitizes the value
for any invalid characters.
public static string SanitizeXmlElementName(this string value)
Parameters
Returns
Remarks
Sanitation rules are as follows:
- Names can contain letters, numbers, and these 4 characters: _ | : | . | -
- Names cannot start with a number or punctuation character
- Names cannot contain spaces
Exceptions
- ArgumentNullException
value
cannot be null.
SanitizeXmlElementText(String, Boolean)
Sanitizes the value
for any invalid characters.
public static string SanitizeXmlElementText(this string value, bool cdataSection = false)
Parameters
value
StringThe String to extend.
cdataSection
Booleanif set to
true
supplemental CDATA-section rules is applied tovalue
.
Returns
Remarks
Sanitation rules are as follows:
- The
value
cannot contain characters less or equal to a Unicode value of U+0019 (except U+0009, U+0010, U+0013) - The
value
cannot contain the string "]]<" ifcdataSection
istrue
.
UnescapeXml(String)
Unescapes the given XML value
.
public static string UnescapeXml(this string value)
Parameters
Returns
- String
The input
value
with an unescaped equivalent.
Exceptions
- ArgumentNullException
value
cannot be null.