Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Fellow Monks,

At present I am creating a web-based intranet post/reply system which will use an amended node syntax of the type showing by "displaytype=xml".
Below there is an example node and the method which is used for parsing these nodes.
As you can see whenever there is a "child" detected, a new instance of the sub parseNode is called and a template output will be returned. At the very end, all nodes (main node and children) are parsed "together" in the correct order and the HTML Output can be printed.
But now I am not sure if those new instances of parseNode() will be too slow (i.e. a post with 25-30 replies). I tried to return only the template object to save a bit of RAM but that doesn't seem to do the trick. By now I do not have the possibility to make an intensive test of my script but I hope it will be fast enough at least in the local area network.

Do you have any suggestions how to integrate the children-nodes more elegantly?

Thank you for your help an sorry about my bad English.

P.S.: I am using XML::Simple and HTML::Template.
sub parseNode { my $node_id = shift(); my $node = XMLin( "$node_id.xml", searchpath => ['nodes'], forcear +ray => ['field', 'child'] ); my $template = HTML::Template->new( filename => "$node->{type}{id} +.html" ); $template->param( node_id => $node->{id}, type => $node->{type}{content}, type_id => $node->{type}{id}, title => $node->{title}, created => &parseTimeBySeconds($node->{created}), updated => &parseTimeBySeconds($node->{updated}), owner => $node->{owner}{content}, owner_id => $node->{owner}{id} ); foreach ( keys( %{$node->{data}{field}} ) ) { $template->param( $_ => $node->{data}{field}{$_}{content} ); } my $children = ''; foreach ( keys( %{$node->{data}{child}} ) ) { $children = $children . &parseNode($node->{data}{child}{$_}{co +ntent}); } $template->param( children => $children ); return $template->output(); }
Here's the node:
<?xml version="1.0" encoding="ISO-8859-1" ?> <node id="432" title="Title of page" created="1001562046" updated="100 +2582217"> <type id="1">Thread</type> <owner id="31337">BioHazard</owner> <data> <field name="doctext">This is test content</field> <child id="1">433</child> <child id="2">435</child> </data> </node>


reading between the lines is my real pleasure

In reply to Node Parser too slow? by BioHazard

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found