Log in

View Full Version : Creating an XML File using PHP



jc_gmk
11-02-2007, 10:52 AM
I have already set up some PHP script to create an XML document.

However the header comes out like this:


<?xml version="1.0"?>

how can I cahnge it so that I get the heading:


<?xml version="1.0" encoding="utf-8"?>

The first part of my php code is:


$doc = new DOMDocument();
$doc->formatOutput = true;

Twey
11-02-2007, 02:45 PM
UTF-8 is the default character set for XML 1.0 documents anyway. There's no need to specify it manually.

jc_gmk
11-02-2007, 02:54 PM
OK, thats cool, thanks!

I do have another question though...

I have developed this script on my local host using PHP 5
however when I upload it to my remote host the script doesn't work.
Found out this is because they are running PHP 4.4.7.

I've contacted my host but they arn't planning on upgrading it until next year, nor do I have the abbility to install anything as I'm using a shared server.

Is there anyway that you know of that I can get round this?

The error message i'm getting is:

Fatal error: Cannot instantiate non-existent class: domdocument

Twey
11-02-2007, 03:22 PM
Tell them that PHP4 becomes officially obsolete in two months.

jc_gmk
11-02-2007, 03:37 PM
I'll try but it doesn't sound like they'll action it in the near future plus I need it up and running in about a week.

Is there a link to any documentation that i can send them to back up this info?


In the meantime is there any other solution?

Surely people have been using PHP4 to create XML documents?

thetestingsite
11-02-2007, 03:55 PM
I'll try but it doesn't sound like they'll action it in the near future plus I need it up and running in about a week.

Is there a link to any documentation that i can send them to back up this info?


This is from php.net



PHP 4 end of life announcement
[13-Jul-2007]

Today it is exactly three years ago since PHP 5 has been released. In those three years it has seen many improvements over PHP 4. PHP 5 is fast, stable & production-ready and as PHP 6 is on the way, PHP 4 will be discontinued.

The PHP development team hereby announces that support for PHP 4 will continue until the end of this year only. After 2007-12-31 there will be no more releases of PHP 4.4. We will continue to make critical security fixes available on a case-by-case basis until 2008-08-08. Please use the rest of this year to make your application suitable to run on PHP 5.

For documentation on migration for PHP 4 to PHP 5, we would like to point you to our migration guide. There is additional information available in the PHP 5.0 to PHP 5.1 and PHP 5.1 to PHP 5.2 migration guides as well.


Hope this helps