Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 29 lines (26 sloc) 0.826 kb
15e3f74 @tautologistics first commit
tautologistics authored
1 A forgiving HTML parser written in JS for Node.
2 Reads in imperfect HTML and spits out a simple object model.
3
4 Usage:
5 var htmlparser = require("node-htmlparser");
6 var rawHtml = "Xyz <script language= javascript>var foo = '<<bar>>';< / script><!--<!-- Waah! -- -->";
00ffae7 @tautologistics Initial push
tautologistics authored
7 var htmlDom = htmlparser.ParseHtml(rawHtml);
8 sys.puts(sys.inspect(htmlDom, false, null));
15e3f74 @tautologistics first commit
tautologistics authored
9
10 Outputs...
11 [ { raw: 'Xyz ', data: 'Xyz ', type: 'text' }
12 , { raw: 'script language= javascript'
13 , data: 'script language= javascript'
14 , type: 'script'
15 , name: 'script'
16 , attribs: { language: 'javascript' }
17 , children:
18 [ { raw: 'var foo = \'<bar>\';<'
19 , data: 'var foo = \'<bar>\';<'
20 , type: 'text'
21 }
22 ]
23 }
24 , { raw: '<!-- Waah! -- '
25 , data: '<!-- Waah! -- '
26 , type: 'comment'
27 }
28 ]
Something went wrong with that request. Please try again.