from static method
XmlText
from(
- String string, {
- bool parseCharacterEntities = true,
- bool isMarkup = false,
- bool trimWhitespace = true,
override
Returns string
as an XML text node.
If parseCharacterEntities
is true
, text values will be parsed
and replace all encoded character entities with their corresponding
character. parseCharacterEntities
must not be null
.
If isMarkup
is true
, the returned XmlText node will not be
character encoded by this method, or the toString method, even
if parseCharacterEntities
is true
. isMarkup
must not be null
.
If trimWhitespace
is true
, unnecessary whitespace between nodes
will be removed and all remaining whitespace will be replaced with
a single space. trimWhitespace
must not be null
.
Implementation
static XmlText from(
String string, {
bool parseCharacterEntities = true,
bool isMarkup = false,
bool trimWhitespace = true,
}) {
string = string.removeComments();
if (trimWhitespace) string = string.trimWhitespace();
if (!isMarkup && parseCharacterEntities) {
string = HtmlCharacterEntities.decode(string);
}
return XmlText(string, isMarkup: isMarkup);
}