parseString method
(Head, Body)
parseString( - String xmlString
)
Implementation
(Head, Body) parseString(String xmlString) {
if (xmlString.trim().isEmpty) {
throw ArgumentError('empty src');
}
final document = XmlDocument.parse(xmlString);
final root = document.rootElement;
Head head = [];
Body body = Context(rawAttributes: const {'id': 'body'});
for (var childNode in root.children.whereType<XmlElement>()) {
if (childNode.name.local == 'head') {
final headElement = _parseNode(childNode);
if (headElement != null) {
head = headElement.children;
}
} else if (childNode.name.local == 'body') {
final bodyElement = _parseNode(childNode);
if (bodyElement is Context) {
body = bodyElement;
}
}
}
_resolveMediaProperties(head, body);
return (head, body);
}