Displaying Multiple XML Files on one page?

Discussion in 'XML' started by bbulzibar, Jun 18, 2004.

  1. bbulzibar

    bbulzibar Guest

    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!
     
    bbulzibar, Jun 18, 2004
    #1
    1. Advertising

  2. 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
     
    Bart Van der Donck, Jun 19, 2004
    #2
    1. Advertising

  3. On 19 Jun 2004 11:01:50 -0700, Bart Van der Donck <> wrote:

    > 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):
    >

    [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
    --
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
     
    Gerald Aichholzer, Jun 21, 2004
    #3
  4. bbulzibar

    b y Guest

    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!
     
    b y, Jun 21, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. loveNUNO
    Replies:
    2
    Views:
    949
    loveNUNO
    Nov 20, 2003
  2. Richard R.
    Replies:
    1
    Views:
    630
    Martin Honnen
    Nov 8, 2004
  3. Replies:
    4
    Views:
    974
    M.E.Farmer
    Feb 13, 2005
  4. Toby Newman
    Replies:
    13
    Views:
    1,160
    Andrzej Adam Filip
    Jan 29, 2007
  5. Dennis Davitt

    Displaying Multiple Datagrids on one page

    Dennis Davitt, Dec 30, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    378
    Charlie Nilsson [MSFT]
    Dec 30, 2003
Loading...

Share This Page