Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Poff

macrumors 65816
Original poster
Sep 16, 2003
1,258
1
Stavanger, Norway
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 :)
 
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
 
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
 
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...
 
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
 
kingjr3 said:
First things first.

[...]

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

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


ac2102 said:
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

[...]

Good luck with your project!

ac2102

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.
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.