Php + Xml

Discussion in 'Web Design & Coding' started by lieb39, Sep 6, 2003.

  1. lieb39

    lieb39 Apple lover, PC User

    Messages:
    526
    Location:
    Australia
    Hello everyone,

    I am wondering how this can be done; basically I want to list all my .xml files in a certain folder on my website, and than if the user clicks on one it will open in a template, that formats the data. I heard that PHP can do this but after 15 minutes of reading a very newbie guide to PHP I gave up. Has anyone ever created a source code for this that free, or is anyone willing to help me?

    Thanks,

    lieb39
     
  2. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    Listing the files is easy enough, see this thread over at X-istence.com

    You'd probably have to change
    PHP:
    print "<li><a href=\"$file\" title=\"$file - $filesize KB\">
    to something like
    PHP:
    print "<li><a href=\"parse.php?file=$file\" title=\"$file - $filesize KB\">
    where-by parse.php is the file which parses the XML file that is passed to it via the $_GET[file] variable.

    How exactly do you want the data from the XML to be formatted?
     
  3. lieb39

    lieb39 Apple lover, PC User

    Messages:
    526
    Location:
    Australia
    Well in my XML file I will have <Date>, <Mood>, <Title> and than my actual text, which will be <Text>. I just basically want this to look nice, each one on a different line, like this;
    Title:[Title, in bold, bigger than the other fonts if possible]
    Date: [Date displayed here]
    Mood: [Mood]
    Text: [Text here, wrapped to fit the screen of course]

    Thats how... And Thank you very much for answering the first part of my question:)


    -lieb39
     
  4. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    Ok, Give me a minute, just need to test the code and so on :)
     
  5. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
  6. lieb39

    lieb39 Apple lover, PC User

    Messages:
    526
    Location:
    Australia
  7. lieb39

    lieb39 Apple lover, PC User

    Messages:
    526
    Location:
    Australia
  8. lieb39

    lieb39 Apple lover, PC User

    Messages:
    526
    Location:
    Australia
    Alright, forget about all my last posts. This is what I have now;
    A page to list my XML files (http://www.centralogn.com/~dan/aussie/journal/)
    A typical XML file I will write (http://www.centralogn.com/~dan/aussie/journal/j1.xml)
    [In case you are wondering, my website is here, http://www.centralogn.com/~dan/aussie/'

    All I need now is a website or whatever, so that when a xml file is clicked on from my page that lists them, it will be passed through a file or whatever to format it. anyone at all?

    Edit, I also need the background to be colour #D9E2E7 , this is very important.

    Edit, Edit: I trying the "print_"<li><a_href=\"$file\"_title=\"$file_-_$filesize_KB\">" but I couldn't find it in my document.

    -lieb39
     
  9. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    the rss url is your xml file.
    to have them displayed when you click a link would require another php page.


    I couldn't get my XML to parse last night, kept feeding me damned errors *slap* but I'll try again later. Does it have to be xml? it would be so much easier with a plain text file and the file(); function..
     
  10. lieb39

    lieb39 Apple lover, PC User

    Messages:
    526
    Location:
    Australia
    hmm.. well i guess i could drop for a .txt file... how would the .txt file itself be formatted?

    -lieb39
     
  11. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    A typical Journal
    Sept 7 2003
    Okay
    this is where my text goes...
    A typical Journal 2
    Sept 8 2003
    Okay again
    this is where more text goes...

    or

    A typical Journal||Sept 7 2003||Okay||this is where my text goes...
    A typical Journal 2||Sept 8 2003||Okay again||this is where more text goes...
     
  12. lieb39

    lieb39 Apple lover, PC User

    Messages:
    526
    Location:
    Australia
    hmm okay, i would go for the break between each line;
    but keep in mind that i have seperate .txt or whatever files for each journal. it will be in .txt files?

    -lieb39
     
  13. lieb39

    lieb39 Apple lover, PC User

    Messages:
    526
    Location:
    Australia
    Okay, I'm off to bed.. Its too late.. its 12:03am and i have school tomorrow... i will put everything together thats posted here tomorrow...

    -lieb39
     
  14. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    File attached. There's a readme file within, and some demo/example text's included. So you can try it out before-hand in a test folder or something :)

    Hmm, It's 4am, perhaps I should sleep.
     
  15. lieb39

    lieb39 Apple lover, PC User

    Messages:
    526
    Location:
    Australia
    All hail Speedy_b!!! He is proclaimed god by lieb39!
    /me owes speedy_b

    -lieb39
     
  16. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    :D glad it works.