Importing from .xml within .html, not .xsl

Discussion in 'Web Design and Development' started by Poff, Apr 18, 2006.

  1. Poff macrumors 65816

    Poff

    Joined:
    Sep 16, 2003
    Location:
    Stavanger, Norway
    #1
    Hello,

    basically, what I want to do is I want to make a fast page in RapidWeaver. Inside there somewhere, I want to add code for the page to look up certain things from an .xml file. I've downloaded the DreamWeaver demo to get a look on how to incorporate .xml, but it insists on using .xsl-files instead of .html-files for this purpose.

    so, is this thing I want to do impossible, importing stuff from a dynamic .xml into a .html-file, or is there a way? Maybe through javascript or something?

    Thanks in advance for any answers :)
     
  2. ac2102 macrumors member

    ac2102

    Joined:
    May 12, 2003
    Location:
    Bristol - England
    #2
    Hi Poff,
    I have a PHP script that can help you out if you like? Drop me a PM if this is any use to you. The same can be achieved using Javascript too, but i am not that clued up on it. Also, the displaying computer may not have it enabled, resulting in no display.
    You would need to be able to program in PHP a bit,

    Let me know,
    ac2102
     
  3. Poff thread starter macrumors 65816

    Poff

    Joined:
    Sep 16, 2003
    Location:
    Stavanger, Norway
    #3
    Thanks a lot for the offer, ac2102. :)

    I found an article describing some of the same here: http://www.site-reference.com/articles/Easy-RSS-Integration.html

    So now I've uploaded the PHP-script here: http://www.dhguitars.com/xmltest/page1/SimpleReader.php , but I'll have to try a bit to get it to work inside my .html file. Apparently, just writing

    PHP:
    <?php
    include("SimpleReader.php");
    ?>
    inside RapidWeaver didn't work. Can this command only be used in a .php-page?

    The only way I've been able to do it till now is using an iFrame, which doesn't really look that good. http://www.dhguitars.com/xmltest/page2/page2.html
     
  4. bootedbear macrumors 6502

    bootedbear

    Joined:
    Sep 13, 2004
    Location:
    Austin, TX
    #4
  5. Poff thread starter macrumors 65816

    Poff

    Joined:
    Sep 16, 2003
    Location:
    Stavanger, Norway
    #5
    Hmm.. but will this generate html, like the php-code? (Generated html equals more hits from Google etc.)
     
  6. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #6
    First things first.

    Are you wanting to do this on the client-side or the server-side?

    Client-side: use AJAX to get the XML, and then use Javascript to "write" HTML. See document.write()

    Server-side: use PHP or another server side technology. Most have XML APIs you can use to read and process the document. Even better, use XSL to transform the XML document into HTML output.

    In any case, sounds like you will need to brush up on some programming...
     
  7. ac2102 macrumors member

    ac2102

    Joined:
    May 12, 2003
    Location:
    Bristol - England
    #7
    Hi Poff,
    You are right about only being able to use php code in .php files. However, you can also make your server parse all html files like php if you are running a server with apache.

    In order to do this you need to create a .htaccess file (the . is there on purpose). There may already be one in your root directory. If there is then add the line

    AddType application/x-httpd-php .php .html

    otherwise, create one in the main directory of you server and add that line.
    The file must be called .htaccess . When i say the root or main directory, i mean the first one that opens when you FTP into your account.

    Now all html pages should be parsed as php, so you will be able to include the lines

    Code:
    <?php
    include("SimpleReader.php");
    ?>
    in your standard html without issue.

    Good luck with your project!

    ac2102
     
  8. Poff thread starter macrumors 65816

    Poff

    Joined:
    Sep 16, 2003
    Location:
    Stavanger, Norway
    #8
    Yup, thats too true. I just wanted to see if this all works out at first before I tried to program a php-file that would change the content of an .xml. I've been wanting to learn PHP for some time, finally here's my excuse.. :D Thanks for good advice. :)


    Thanks for the code. :) I guess my server must be using Apache, because this code did something, only it did the wrong thing. Suddenly every .html file I accessed tried downloading itself to my hard-drive, but .mp3-files for example, reacted the usual way. I'll post a screenshot.
     
  9. ac2102 macrumors member

    ac2102

    Joined:
    May 12, 2003
    Location:
    Bristol - England
    #9
    OK, from what i remember, this is something to do with server side includes conflicting with the .php type.

    I think that the line:

    addtype text.html .php

    fixes it, but i can't remember whether you need to add it as well, or replace the line i told you to put in before. Try both and see what happens, it can't do any harm!

    So sorry to be a little vague about this, but i have only encountered this problem once on an old server.

    Best of luck!
    ac2102
     
  10. Poff thread starter macrumors 65816

    Poff

    Joined:
    Sep 16, 2003
    Location:
    Stavanger, Norway
    #10
    Seems I'm not the only one with this problem.

    http://www.webmasterworld.com/forum92/260.htm

    ..maybe I'll have to send a mail to my ISP and ask.

    Anyways, thanks for great help! Now I know what I'm looking for. I'll post updates to this thread as I come closer to my goal.
     

Share This Page