Need help with TreeBuilder::XPath in perl

use strict; use warnings; use LWP::Simple; use HTML::TreeBuilder::XPath; my $url='file:///C:/Users/Rockstar/workspace/abc/globals_func.html +'; my $page = get($url) or die $!; my $p = HTML::TreeBuilder::XPath->new_from_content( $page); my @trips= $p->findnodes( '//div[@class="contents"]'); foreach my $trip (@trips){ print $trip->as_text."\n"; }

After running it in an HTML file,I get output(ALL in one line) as ChainCtrlBuildChain() : ChainController.cChainCtrlDumpChain() : ChainController.cChainCtrlExit() : ChainController.cChainCtrlGetBitStreamChan() : ChainController.cChainCtrlInit() : ChainController.c.

I but want them to be shown as below(one row per value).

ChainCtrlBuildChain() : ChainController.c

ChainCtrlDumpChain() : ChainController.c

ChainCtrlExit() : ChainController.c

ChainCtrlGetBitStreamChan() : ChainController.c

ChainCtrlInit() : ChainController.c.

Kindly help me what am i missing my HTML file(displaying only the HTML code of "contents")

<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 -->

In reply to using TreeBuilder in perl by anirban0328

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.