// creates a new DOM document from a string
$doc = new DOMDocument("1.0", "UTF-8");
$doc->loadXML($string);
Hello Everybody,I can't figure out how to create a DOM document from a string. It is very straightforward in PHP:
// creates a new DOM document from a string
$doc = new DOMDocument("1.0", "UTF-8");
$doc->loadXML($string);But I have no idea how to do this in Dart, using the native functions and classes.
void main() { String html = ''' <span id="foo">Foo in a span</span> '''; SpanElement span = new DocumentFragment.html(html).querySelector('#foo'); print(span.text);}
Try DomParser.parseFromString