[SOLVED] Firefox and xml

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Firefox and xml

Post by Jean-Yves »

Hi there,

I have an online multi-player game written in PHP/MySQL. One feature which I've just added is an XML output of a player's game stats. There are some 3rd party tools that use this XML to create offline views of games to allow players to plan their strategies whilst their "enemies" are taking their turns.

A PHP script basically writes the XML out to the page. Ultimately, I intend to provide this as a web service (but first things first!).

Anyway, here's the issue: with IE, viewing the XML shows it with the collapsing xml-tree view, even though the file name ends with .php
In Firefox, it just writes out the values within the tags as a stream of text, and the xml tags are only visible in source view. If the xml had a .xml extension, this would show correctly. Not a big deal as the page is there as crude API and not really for "human" reading, but a pain when testing.

So is it possible to either tweak Firefox to display xml in a tree view irrespective of filename extension and thus avoid having to write the file to the server first with an xml extension?

The file has the standard xml header of:

Code: Select all

<?xml version="1.0" ?>
Thanks for any help.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try using:

Code: Select all

<?php

header("Content-type: text/xml");

?>
in the xml formatting script.. (very top of the file)
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

Excellent - works a treat. Should have figured that out myself (shamefaced!).

Many thanks :)
Post Reply