applyMap static method
Implementation
static String? applyMap(String? xml, Map? map, {String? source, bool caseSensitive = true, String? prefix, bool encode = false})
{
if ((map != null) && (xml != null)) {
map.forEach((key, value)
{
String oldValue = "{${S.isNullOrEmpty(prefix) ? (S.isNullOrEmpty(source) ? '' : '${source!}.') : prefix!}$key}";
String? newValue = (value ?? '').toString();
if ((encode) && (Xml.hasIllegalCharacters(newValue))) newValue = Xml.encodeIllegalCharacters(newValue);
if (caseSensitive) {
xml = xml!.replaceAll(oldValue, newValue!);
} else {
try
{
xml = xml!.replaceAll(RegExp(oldValue, caseSensitive: false), newValue!);
}
catch(e)
{
xml = xml!.replaceAll(oldValue.toLowerCase(), newValue!);
xml = xml!.replaceAll(oldValue.toUpperCase(), newValue);
xml = xml!.replaceAll(oldValue, newValue);
}
}
});
}
return xml;
}