in reply to HTML::TreeBuilder. Redirect tree->dump to an array

Maybe ->as_HTML does what you want? That method is mentioned immediately after ->dump in the HTML::Element documentation.

As you haven't told us what you want to achieve, or what ->dump actually does, all I can do is guess...

Replies are listed 'Best First'.
Re^2: HTML::TreeBuilder. Redirect tree->dump to an array
by mm&mm (Initiate) on May 05, 2008 at 10:56 UTC
    Yes,
    dump() is a method of the HTML::Element module, which is required by HTML::TreeBuilder.
    I quote from CPAN:

    $h->dump()
    $h->dump(*FH) ; # or *FH{IO} or $fh_obj
    Prints the element and all its children to STDOUT (or to a specified filehandle), in a format useful only for debugging. The structure of the document is shown by indentation (no end tags).

    This is a sample of what the output of tree-> dump looks like:
    <html> @0 <head> @0.0 <title> @0.0.0 <~text text="WO trail BARCELON/GAR - GERONA/CAR - 30N - 1"> @0.0 +.0.0 <meta content="text/html; charset=iso-8859-1" http-equiv="Content- +Type"> @0.0.1 <meta content="MSHTML 6.00.2800.1589" name="GENERATOR"> @0.0.2 <meta content="Mozilla/4.6 [fr] (WinNT; I) [Netscape]" name="GENER +ATOR"> @0.0.3 <body alink="#ff0000" bgcolor="#ffffff" link="#000080" text="#000000 +" vlink="#800080"> @0.1 <a name="HEADER"> @0.1.0 <center> @0.1.1 <h1> @0.1.1.0 <font size="+2"> @0.1.1.0.0 <~text text="WORK ORDER"> @0.1.1.0.0.0 <b> @0.1.6 <font size="-2"> @0.1.6.0 <~text text="trail"> @0.1.6.0.0 <table bgcolor="#66ffff" border=0 cellspacing=0 cols=8 width="100% +"> @0.1.7 <tbody> @0.1.7.0 <tr> @0.1.7.0.0 <td> @0.1.7.0.0.0 <font size="-2"> @0.1.7.0.0.0.0 <~text text="Node A"> @0.1.7.0.0.0.0.0 <td> @0.1.7.0.0.1 <font size="-2"> @0.1.7.0.0.1.0 <~text text="Node Z"> @0.1.7.0.0.1.0.0
    In my code, this is what's written to an output file, and what I would rather have assigned to an array instead.