在dart中解析HTML字符串到dom [英] in dart parse HTML string to dom

查看:432
本文介绍了在dart中解析HTML字符串到dom的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在dart中,

我要解析字符串<!DOCTYPE HTMT>< html>< head> / head>< body> ....< / body>< / html> ,以便我可以在生成的dom中操作元素。我知道在Jquery,有$ .parseHTML处理它。但我在飞镖上找不到任何办法。
谢谢。

I want to parse a string "<!DOCTYPE HTMT><html><head></head><body>....</body></html>" to a dom so that I can manipulate element in the generated dom. I know in Jquery, there is $.parseHTML to deal with it. But I can not find any way in dart. Thank you.

(我试过html2lib,但输出Document不能使用 query(。classname)以选择。)

(I have tried html2lib, but the output Document cannot use query(".classname") to select.)

推荐答案

尝试 html5lib

您也可以考虑使用Dart的XML解析器,例如 dart-xml ,取决于HTML的性质。

You could also consider an XML parser for Dart like dart-xml depending on the nature of your HTML.

这篇关于在dart中解析HTML字符串到dom的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆