Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: using TreeBuilder in perl

by Khen1950fx (Canon)
on Jul 29, 2013 at 11:55 UTC ( #1046854=note: print w/ replies, xml ) Need Help??

in reply to using TreeBuilder in perl

HTML::FormatText does exactly what you want.

#!/usr/bin/perl use strict; use warnings; use utf8::all; use HTML::FormatText; use HTML::TreeBuilder::XPath; my $page = q{ <div class="contents"> &#160;<ul> <li>ChainCtrlBuildChain() : <a class="el" href="_chain_controller_8c.html#acb2c56087a2072b6445 +a54c17662d118">ChainController.c</a> </li> <li>ChainCtrlDumpChain() : <a class="el" href="_chain_controller_8c.html#a13ed5a02bf232b115b9a5 +8cdd13dadd7">ChainController.c</a> </li> <li>ChainCtrlExit() : <a class="el" href="_chain_controller_8c.html#a9e30e46ebc5411537efe9 +5a286e27cb4">ChainController.c</a> </li> <li>ChainCtrlGetBitStreamChan() : <a class="el" href="_chain_controller_8c.html#a00faa6e64ea466d4ec573 +39017e57e71">ChainController.c</a> </li> <li>ChainCtrlInit() : <a class="el" href="_chain_controller_8c.html#aed300a388eff2fa9c7565 +025982faab1">ChainController.c</a> </li> </ul> </div><!-- contents --> }; my $tree = HTML::TreeBuilder::XPath->new_from_content($page); my(@trees) = $tree->findnodes('//div[@class="contents"]'); foreach $tree(@trees) { my $formatter = HTML::FormatText->new( leftmargim => 0, rightmargin => 50, ); print $formatter->format($tree); }

Comment on Re: using TreeBuilder in perl
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1046854]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2015-11-27 13:43 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (729 votes), past polls