Please review How (Not) To Ask A Question. I think this is xpath
#!/usr/bin/perl -- use strict; use warnings; use HTML::TreeBuilder; { my $tree = HTML::TreeBuilder->new(); $tree->look_down(qw!_tag body!)->push_content( [ ul => map [ 'li', $_ ], qw(Peaches Apples Pears Mangos) ], [ table => map [ tr => [ td => $_ ] ], 1 .. 3 ], ); print $tree->as_HTML( '', ' ' ); sub HTML::Element::addressx { return join( '/', '/', # // ROOT reverse( # so it starts at the top map { my $n = $_->pindex() || '0'; my $t = $_->tag; $t . '['. $n .']' } # so that root's undef -> '0' $_[0], # self and... $_[0]->lineage ) ); } ## end sub HTML::Element::addressx for my $td ( $tree->look_down( _tag => 'td' ) ) { print $td->addressx, "\n"; } ## end for my $td ( $tree->look_down...) $tree->delete; undef $tree; } __END__ <html> <head> </head> <body> <ul> <li>Peaches<li>Apples<li>Pears<li>Mangos</ul> <table> <tr> <td>1</td> </tr> <tr> <td>2</td> </tr> <tr> <td>3</td> </tr> </table> </body> </html>
//html[0]/body[1]/table[1]/tr[0]/td[0] //html[0]/body[1]/table[1]/tr[1]/td[0] //html[0]/body[1]/table[1]/tr[2]/td[0]

In reply to Re: How to find an xpath from an web page by Anonymous Monk
in thread How to find an xpath from an web page by perladdict

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.