bbulzibar wrote:
I have a directory filled with XML files. These are small files which
contain something like:
<date>6/10/2004</date>
<name>bbulzibar</name>
<computer>Dell</computer>
Is there anyway I can aggregate 100 of these files and display them on
ONE page?
Several approaches are possible depending on what exactly you want.
This javascript will read your xml files and put them in an array for
your webpage (Obviously, your browser would need to understand xml for
this to work):
---------------------------
<html>
<body>
<script language="javascript">
// put your xml files here:
var xmlFiles = new Array("first.xml","second.xml","third.xml");
var all = new Array();
for(loop=0;loop<(xmlFiles.length);loop++)
{
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load(xmlFiles[loop]);
all[loop] = xmlDoc.documentElement.xml;
}
alert(all); // report
</script>
</body>
</html>
---------------------------
I would rather work with a server process. This is a cgi approach, it
will put your xml files in a perl array:
---------------------------
#!/usr/bin/perl
print "Content-Type: text/xml\n\n";
my $count=0;
# put your xml files here:
my @xmlfiles = ("first.xml","second.xml","third.xml");
for $file(@xmlfiles)
{
open (READ, $file)||die"$!";
flock(READ, 1) || die "Can't lock xml: $!";
while (<READ>)
{ $all[$count].=$_ }
close READ;
$count++;
}
print @all; # report
---------------------------
Once you have the array, you can display the xml content just as you
want.
Hope this helps
Bart