var g = new Grabber( "Grabber Test HTML Parser", "GBR" );
g.onRun = function( lp ) { this.test = "my test variable in grabber object";
var hp = new HTMLParser( "<body onload=\"\"><img src=\"ignored\" /><p align=\"center\" align=\"middle\">nonsense<span class=\"bold\" align=\"center\">this is <!-- a bit of a comment --> some text</span></p></body>" ); hp.m_grabber = this; hp.m_lp = lp;
hp.onGotTag = function( tag, params ) { var paramList = "";
if( params.align ) { if( typeof params.align == "object" ) { for( var n = 0; n < params.align.length; n++ ) { paramList += " align[" + n + "]=" + params.align[ n ] + ","; } } else { paramList += " align=" + params.align + ","; } }
this.m_lp.writeLog( "Found tag: " + tag + paramList ); }
hp.onGotEndTag = function( tag ) { this.m_lp.writeLog( "Found end tag: " + tag ); }
hp.onGotText = function( text ) { this.m_lp.writeLog( "Found text: " + text ); }
hp.onEndDoc = function() { this.m_lp.writeLog( "Finished" ); }
hp.onGotComment = function( text ) { this.m_lp.writeLog( "Found comment: " + text ); this.m_lp.writeLog( "Accessing test variable: " + this.m_grabber.test ); }
hp.parse( "body span a p div" );
return false; }
|