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:
1. Names can contain letters, numbers, and these 4 characters: _ | : | . | -
2. Names cannot start with a number or punctuation character
3. Names cannot contain spaces
Exceptions
- ArgumentNullException
value
cannot be null.
SanitizeXmlElementText(string, bool)
Sanitizes the value
for any invalid characters.
public static string SanitizeXmlElementText(this string value, bool cdataSection = false)
Parameters
value
stringThe string to extend.
cdataSection
boolif set to
true
supplemental CDATA-section rules is applied tovalue
.
Returns
Remarks
Sanitation rules are as follows:
1. The value
cannot contain characters less or equal to a Unicode value of U+0019 (except U+0009, U+0010, U+0013)
2. The value
cannot contain the string "]]<" if cdataSection
is true
.
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.