Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

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

Hi,

I am running ASPerl 5.6.1 on Windows 2000 using Apache as the web server. I need a quick solution to display a page while our production Helpdesk has it's legs in the air. This solution may need to be used again in the future, so I would like to start with a quick win but expand this into something more a little later.

The Problem: I have an automated process that creates small xml files in several dirs. These files can number upwards of 200 files per dir and about 7 dirs.

home/
dirA/
dirB/
dirC/

Each XML file looks similar to the following:

<?xml version="1.0"?> <opt> <Agent_Class>Backup</Agent_Class> <MD>dirA</MD> <Agent_Instance>NetBackup</Agent_Instance> <Date>2003/12/08</Date> <Server>ServerABC</Server> <Instance_Detail>Backup Problems ServerABC:57</Instance_Detail> <Time>08:04:58</Time> <Header>X-CALL</Header> <State>CRITICAL</State> </opt>

Basically I need to display a table with the dir name and some of the contents of all the files in its dir. Something like:

Managing ServerCall Details
dirA
ServerABC - Backup - NetBackup - Backup Problems ServerABC:57
ServerDEF - Drive - Space - Drive C: is out of disk space

This is a snippet of what I have at the moment which is proving FAR too slow:
if (opendir (DIR, $path)) { while( my $dir = readdir( DIR ) ) { next if( ( "." eq $dir ) || ( ".." eq $dir ) ); if (-d "$path/$dir") { print "<TR><TD>$dir</TD><TD></TD></TR>\n"; print "<TR><TD>$dir</TD>\n"; if (opendir (CUSTDIR, "$path/$dir")) { my $count = 0; while (my $file = readdir( CUSTDIR)) { next if (("." eq $file) || (".." eq $file)); $count++; if (eval { $callvals = XMLin("$path/$dir/$file") } +) { # $calldetails{$callvals->{Server}} = "$callval +s->{State} $callvals->{Agent_Class} $callvals->{Agent_Instance} $call +vals->{Instance_Detail}"; print "<TR><TD></TD><TD><B>$callvals->{Server} +</B> - $callvals->{State} - $callvals->{Agent_Class} - $callvals->{Ag +ent_Instance} - $callvals->{Instance_Detail}</TD></TR>\n"; } else { die "Cannot Read $path/$dir/$file: $@\n"; } } close (CUSTDIR); print "<TD>$count XML files</TD></TR>\n"; } else { die "Cannot find path $path/$dir: $!\n"; } } } close(DIR); } else { die "Cannot find path $path: $!\n"; }
I thought of putting all the data from the files into a hash so I only had to process the relevant bits when I build the web page.

What can I do to be able to read these files and put some of the detail in a web page before the web page times out or tries to refresh itself (120 Secs)?

It must be said that I am using CGI, but that cgi/html is NOT where my little experience lies..

-----
Of all the things I've lost in my life, its my mind I miss the most.

In reply to Fast processing of XML files for CGI by AcidHawk

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 browsing the Monastery: (8)
As of 2024-04-19 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found