setDocStringValue method
void
setDocStringValue({})
Implementation
void setDocStringValue({
required XmlDocument doc,
required String name,
required String attributeName,
required String targetKey,
required String targetValue,
bool autoFill = false,
}) {
List<XmlElement> list = doc.findAllElements(name).toList();
final targetElements = list.where((e) => e.getAttribute(attributeName) == targetKey).toList();
if (targetElements.isEmpty) {
if (autoFill) {
final newElement = XmlElement(XmlName.fromString(name));
newElement.setAttribute(attributeName, targetKey);
newElement.innerText = targetValue;
list.first.parent?.children.add(newElement);
}
} else {
for (XmlElement e in targetElements) {
e.innerText = targetValue;
}
}
}