Development Integrating XML into HTML

Discussion in 'Software' started by OneSeventeen, 3 Feb 2003.

  1. OneSeventeen

    OneSeventeen Oooh Shiny!

    Joined:
    3 Apr 2002
    Posts:
    3,454
    Likes Received:
    2
    Say I have an external .XML file that looks similar to this:
    Code:
    <MBM_INTERVAL>
    <Log Time="8:38:17 PM" T_CPU_Temp="86º F" Date="2/2/2003" CPU="907 MHz" C_CPU0="21.00 %"/>
    <Log Time="8:37:17 PM" T_CPU_Temp="86º F" Date="2/2/2003" CPU="907 MHz" C_CPU0="5.00 %"/>
    </MBM_INTERVAL>
    How hard would it be to create an HTML document that would add the data into a table?


    EDIT:: The .xml document can be found here
     
  2. linear

    linear Minimodder

    Joined:
    5 Oct 2001
    Posts:
    4,393
    Likes Received:
    1
    If you have access to a scripting language that does regular expressions, then it would be cake. PHP or Perl would qualify, I'm sure others would as well (dunno about ASP).

    PHP has XML support fi it was compiled with the expat libraries (default I think) but for something the size of your example, it's a lot of overhead when a simple regex or two would be adequate.

    The format doesn't change, right? This looks like the MBM data you were talking about in another post?
     
  3. OneSeventeen

    OneSeventeen Oooh Shiny!

    Joined:
    3 Apr 2002
    Posts:
    3,454
    Likes Received:
    2
    Correct, this is the same MBM data.
    I am thinking of just using server side includes to include the Interval.html file into a CSS formatted page. The only problem is MBM sets the width of the table to 1000, which is slightly larger than it needs to be.
    I'm thinking of possibly making a CSS file that will force all Tables without a particular class to look a certain way, then just make all the other tables in my document under a specific class.


    I'm a hybrid loser, I want simple data readouts, but I also want them to look nice... I'm stuck between databasing and design! :p

    I'm also stuck with a server that does not support any scripting whatsoever. Server-Side-Includes are basically the only thing I can do.

    Ideas? (I may just start 'donating' plasma and using the money for a decent host)
     
  4. linear

    linear Minimodder

    Joined:
    5 Oct 2001
    Posts:
    4,393
    Likes Received:
    1
  5. stanleym

    stanleym What's a Dremel?

    Joined:
    18 Jul 2002
    Posts:
    100
    Likes Received:
    0
    The easiest way to change XML to another format like this is to use XSLT (extensible stylesheet language transitions). A google for xslt example gives up a few useful examples.

    I have a small example that you should be able to mess around with and get what you want from it.. I'll upload it..xslt example

    Edit: I've had a poke around with MBM. If you go to the "Interval & SysLog" section and scroll down to the "XSL entry in XML files" editbox, then chuck this line in
    that adds the necessary gubbins to link to the xsl stylesheet.

    Then just make sure ..this file is in the same directory as the MBM dumped XML file. Hope this isn't too late, but it does work. Your original file with the above line added produces this.You can modify the xsl file to make it prettier obv.

    Edit (again): Uh, Brinkster is the worst thing ever for linking to files, you can get to the above 2 files from here.
     
    Last edited: 13 Feb 2003

Share This Page