fromMap static method
Returns a single depth XmlDocument from a flat map
XmlDocument temp = fromMap(map: {'TEXT': 'Line 1', 'TEXT': 'Line2', 'BUTTON': 'Click Me' }, rootName: 'TEMPLATE');
Implementation
static XmlDocument fromMap({Map? map, String rootName = 'ROOT'}) {
XmlDocument document = XmlDocument();
XmlElement root = XmlElement(XmlName(rootName));
document.children.add(root);
map?.forEach((key, value) {
if (value != null) {
try {
XmlElement node = XmlElement(XmlName(key.toString()));
node.children.add(XmlCDATA(value.toString()));
root.children.add(node);
} catch (e) {
Log().exception(e,
caller:
"xml.dart => XmlDocument fromMap({Map map, String rootName = 'ROOT'})");
}
}
});
return document;
}