Hello everyone thanks for sparing some time and looking at this thread – I need some help with inserting new element in to a tree not directly but through a variable possibly
code – works fine but does not fully meet my needs
...
my $ele = $tree->look_down(_tag=> 'div',id=>'right');
$ele->delete_content();
my $i=0;
while ($i < $right_panel) {
#element friendly node
$ele->push_content(['strong'], "$matrix_title[$i]",['p'],"$mat
+rix_summary[$i]",['br'],['br'],['a', {href=>"art.cgi?art=$matrix_id[$
+i]"}, "Read on ... ", ],['br'],['hr'],['br']);
$i++;
}
...
print $cgi->header();
print $tree->as_HTML();
basically I need to replace some symbols (user friendly tags) in
$matrix_title[$i],$matrix_summary[$i] ( which are part of the news article fetched from the database and inserted in to a tree through push_content()) with valid tree element tags .
e.g:
\n -> [br]
<p> -> [p]
[link = permonks.org] - > ['a', {href=>"perlonks.org"}]
etc...
– and have it all as a valid tree element.
Thanks,
Update
Found one partial Solution -
...
while ($i < $right_panel) {
$matrix_summary[$i]=~s/\n/<br>/g;
#my $htm_elem = qq(['strong'], "$matrix_title[$i]",['p'],"$matrix_
+summary[$i]",['br'],['br'],['a', {href=>"art.cgi?art=$matrix_id[$i]"}
+, "Read on ... ", ],['br'],['hr'],['br']);
my $li=HTML::Element->new('~literal','text', qq(<strong> $matrix_t
+itle[$i]</strong><p>$matrix_summary[$i]</p><br><a href="art.cgi?art=$
+matrix_id[$i]">Read on ...</a><br><hr><br>)
);
$ele->push_content($li);
$i++;
}
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.