perlquestion
BioHazard
Fellow Monks,<br />
<br />
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".<br />
Below there is an example node and the method which is used for parsing these nodes.<br />
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.<br />
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.<br />
<br />
Do you have any suggestions how to integrate the children-nodes more elegantly?<br />
<br />
Thank you for your help an sorry about my bad English.<br />
<br />
P.S.: I am using XML::Simple and HTML::Template.
<code>
sub parseNode
{
my $node_id = shift();
my $node = XMLin( "$node_id.xml", searchpath => ['nodes'], forcearray => ['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}{$_}{content});
}
$template->param( children => $children );
return $template->output();
}
</code>
Here's the node:
<code>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<node id="432" title="Title of page" created="1001562046" updated="1002582217">
<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>
</code>
<br />
<hr />
<font face="verdana" size="2">reading between the lines is my real pleasure</font>