fromXmlStringList<T extends TagXml> static method
- string xml,
- T constructor()
Create a list of instances of T
from a XML string and using the provided constructor
.
The constructor
is a function that creates a new instance of T
and returns it.
Provide the tagName if T
name is different fom tagName.
Implementation
static Iterable<T> fromXmlStringList<T extends TagXml>(string xml, T Function() constructor) {
if (xml.isBlank) return [];
try {
var tags = XmlDocument.parse(xml).findAllElements(constructor().tagName);
var typedTags = tags.map((x) => mutate(x, constructor)).nonNulls.toList();
return typedTags;
} catch (e) {
consoleLog("$e", error: e);
return [];
}
}