What I would like to be able to do, is define a section of a page, containing several different _tag's.
The HTML in question is:
<table border=0 cellspacing=2 width=100%>
...
<tr>
<td class=td1 id=centered valign=top><A HREF=http://SOME_LINK>1 </
+A></td>
<td class=td1 valign=top>
<script language="javascript">
var recordLink="<A HREF=SOME_LINK>1 </A>";
recordLink = recordLink.substring(0, recordLink.indexOf(">"));
document.write(recordLink);
document.write(">");
</script>
SOME_TEXT</a></td>
<!--
<td class=td1 valign=top>SOME_DATA</td>
-->
</tr>
, and I'm currently reading it with:
my @comments = $tree->look_down ('_tag', '~comment');
my @lnk_details = $tree->look_down ('_tag', 'script');
The problem with this is that I have no (easy) control over checking whether there actually exist a "comment" part together with the link (contained in the "script"-tag).
So I'm reading both the arrays of data together, without knowing whether they have the same number of elements, or even if one element in "comments" is paired with the element in the same position in "lnk_details".
Is there a way to make TreeBuilder extract sections of an HTML-page defined by consecutive tags, and pair those together for further parsing?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.