Displaying Multiple XML Files on one page?

B

bbulzibar

I have a directory filled with XML files. These are small files which
contain something like:

Code:
<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?

I found this thing called XQEngine. It is
"a full-text search engine for XML documents. Utilizing XQuery as its
front-end query language, it lets you interrogate collections of XML
documents for boolean combinations of keywords, much as Google and
other search engines let you do for HTML."


Does anyone have experience with doing this in XML or have experience
with XQEngine? Do I even need XQEngine? Can I just use XQL?

Any help would be greatly appreciated!
 
B

Bart Van der Donck

bbulzibar said:
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
 
G

Gerald Aichholzer

bbulzibar said:
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):
[SNIP: Code]

I would rather work with a server process. This is a cgi approach, it
will put your xml files in a perl array:
[SNIP: Code]

In the latter case you should also take a look at the Cocoon project:
http://cocoon.apache.org

HTH,
Gerald
 
B

b y

I ended up using a solution like this, (not nearly as robust as yours).
It just goes line by line with php. As long as the files are formatted
the same, which they are. Thanks for all your help!

<html>
<body>
<?php
if ($handle = opendir('errors')) {
while ((false !== ($file = readdir($handle))) & ($i<100 )) {
$i++;
$filearray = file('errors/'.$file);
foreach ($filearray as $ind => $line) {
if ($ind == 0) {
$tmp = "<b>";
$tmp = $tmp.$line;
$tmp = $tmp."</b>";
}
elseif ($ind == 1) {
$tmp = "<font color=\"#0033FF\">";
$tmp = $tmp.$line;
$tmp = $tmp."</font>";
}
elseif ($ind == 2) {
$tmp = "";
$tmp = $tmp.$line;
}
$html = $html.$tmp."<br>";
}
}
closedir($handle);
echo $html;
}
?>
</body>
</html>

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top