Class XmlUtilityExtensions
Extension methods for the XmlUtility class.
Inheritance
Namespace: Cuemon.Xml
Assembly: Cuemon.Xml.dll
Syntax
public static class XmlUtilityExtensions
Methods
| Improve this DocEscapeXml(String)
Escapes the given XML System.String.
Declaration
public static string EscapeXml(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The XML System.String to escape. |
Returns
Type | Description |
---|---|
System.String | The input |
RemoveXmlNamespaceDeclarations(Stream)
Remove the XML namespace declarations from the specified System.IO.Stream value
.
Declaration
public static Stream RemoveXmlNamespaceDeclarations(this Stream value)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | value | An XML System.IO.Stream to purge namespace declarations from. |
Returns
Type | Description |
---|---|
System.IO.Stream | A System.IO.Stream object representing the specified |
RemoveXmlNamespaceDeclarations(Stream, Boolean)
Remove the XML namespace declarations from the specified System.IO.Stream value
.
Declaration
public static Stream RemoveXmlNamespaceDeclarations(this Stream value, bool omitXmlDeclaration)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | value | An XML System.IO.Stream to purge namespace declarations from. |
System.Boolean | omitXmlDeclaration | if set to |
Returns
Type | Description |
---|---|
System.IO.Stream | A System.IO.Stream object representing the specified |
RemoveXmlNamespaceDeclarations(Stream, Boolean, Encoding)
Remove the XML namespace declarations from the specified System.IO.Stream value
.
Declaration
public static Stream RemoveXmlNamespaceDeclarations(this Stream value, bool omitXmlDeclaration, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | value | An XML System.IO.Stream to purge namespace declarations from. |
System.Boolean | omitXmlDeclaration | if set to |
System.Text.Encoding | encoding | The text encoding to use. |
Returns
Type | Description |
---|---|
System.IO.Stream | A System.IO.Stream object representing the specified |
SanitizeElementName(String)
Sanitizes the elementName
for any invalid characters.
Declaration
public static string SanitizeElementName(this string elementName)
Parameters
Type | Name | Description |
---|---|---|
System.String | elementName | The name of the XML element to sanitize. |
Returns
Type | Description |
---|---|
System.String | A sanitized System.String of |
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
SanitizeElementText(String)
Sanitizes the text
for any invalid characters.
Declaration
public static string SanitizeElementText(this string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The content of an XML element to sanitize. |
Returns
Type | Description |
---|---|
System.String | A sanitized System.String of |
Remarks
The text
is sanitized for characters less or equal to a Unicode value of U+0019 (except U+0009, U+0010, U+0013).
SanitizeElementText(String, Boolean)
Sanitizes the text
for any invalid characters.
Declaration
public static string SanitizeElementText(this string text, bool cdataSection)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The content of an XML element to sanitize. |
System.Boolean | cdataSection | if set to |
Returns
Type | Description |
---|---|
System.String | A sanitized System.String of |
Remarks
Sanitation rules are as follows:
- The
text
cannot contain characters less or equal to a Unicode value of U+0019 (except U+0009, U+0010, U+0013) - The
text
cannot contain the string "]]<" ifcdataSection
istrue
.
UnescapeXml(String)
Unescapes the given XML System.String.
Declaration
public static string UnescapeXml(this string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The XML System.String to unescape. |
Returns
Type | Description |
---|---|
System.String | The input |