Table of Contents

SanitizeXmlElementText Method

Definition

Namespace
Cuemon.Xml
Assemblies
Cuemon.Xml.dll
Source
src/Cuemon.Xml/Extensions/StringDecoratorExtensions.cs

SanitizeXmlElementText(IDecorator<string>, bool)

Sanitizes the enclosed string of the specified decorator for any invalid characters.

public static string SanitizeXmlElementText(this IDecorator<string> decorator, bool cdataSection = false)

Parameters

decorator IDecorator<string>

The IDecorator<T> to extend.

cdataSection bool

if set to true supplemental CDATA-section rules is applied to the enclosed string of the specified decorator.

Returns

string

A sanitized string of the enclosed string of the specified decorator.

Remarks

Sanitation rules are as follows:
1. The enclosed string of the specified decorator cannot contain characters less or equal to a Unicode value of U+0019 (except U+0009, U+0010, U+0013)
2. The enclosed string of the specified decorator cannot contain the string "]]<" if cdataSection is true.

Exceptions

ArgumentNullException

decorator cannot be null.