Results 1 to 4 of 4

Thread: Styling XML...

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Styling XML...

    Hmm, well, just finished fixing my XML to HTML script in PHP, and now I figure I may as well find out if I've wasted my time.

    I'm trying to display an XML timetable,
    http://www.pcmstudios.com/uni/timetable.php

    As that.

    The XML can be found here,
    http://www.pcmstudios.com/uni/timetabledata/pjmcc.xml

    Obviously I can change the structure of the XML as needed... but can I style it to make it look like a table with having to loose the readability of the XML document? (well, it was readable in the beginning, this rewrite has screwed that up abit)

    Thanks inadvance.
    Don't Rate my posts.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Styling XML...

    Off the top of my head I'm not entirely sure how you'd display XML elements as columns, so I think it would be easiest if in the XML you defined the rows instead. Then you could display it quite easily using a CSS 2 table. It would however probably mean that your XML markup would be longer, so if what you've got now works I suggest stick with it. Either that, or you could try making an XSL transformation script... but that would not really have any advantage over the PHP in this particular case, only if you wanted to display the XML independently using a browser only.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Styling XML...

    Of course it's possible. You only need to add a reference to an XSL file in your XML file. So the readability is maintained to code.

    You'd most likely need to pay attention to for-each in XSL.
    http://www.w3schools.com/xsl/xsl_for_each.asp

  4. #4

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: Styling XML...

    Quote Originally Posted by mendhak
    Of course it's possible. You only need to add a reference to an XSL file in your XML file. So the readability is maintained to code.

    You'd most likely need to pay attention to for-each in XSL.
    http://www.w3schools.com/xsl/xsl_for_each.asp
    Aren't they out of order? Consider HTML works by Row while the XML file is by Day? (aka Column)



    Just curious about the power of XML... can I get it to calculate the number of days to go till a certain Day? Trying to do an assignment list and there due dates, and in the PHP version I had a days to go field, as well as being able to change the rows colour once the day had passed, so would be great if I could include that feature as well.
    Don't Rate my posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width