-
Notifications
You must be signed in to change notification settings - Fork 31
/
demo.html
36 lines (34 loc) · 1.04 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<title>simple html parser</title>
</head>
<body>
<p>simple html parser</p>
<script type="text/javascript" src="./simplehtmlparser.js"></script>
<script type="text/javascript">
var parser = new SimpleHtmlParser();
var html = '<div id="app">\n<p v-show="show">hello parser</p>\n<!--my-comment-->\n</div>';
console.log(html)
// 处理器
var handler = {
startElement: function (sTagName, oAttrs) {
console.log(sTagName, oAttrs)
},
endElement: function (sTagName) {
console.log(sTagName, 'end')
},
characters: function (s) {
console.log(s, 'characters')
},
comment: function (s) {
console.log(s, 'comment')
}
};
// parse
parser.parse(html, handler);
</script>
</body>
</html>