Generating xml with php to use xslt client side
Posted: Tue Sep 06, 2005 1:11 pm
I am trying to generate xml that will be processed client side with an associated xslt template. My php generates well-formed xml and if I manually copy and paste the ouput to an .xml file, it generates xhtml properly. However, when the php is accessed directly, I get this error:
How do I set the content type in php? Is this my problem?
Thank you huge for any help.
Researching the problem, I noticed this at w3schools.com:The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
Invalid at the top level of the document. Error processing resource 'file:///C:/Documents and Settings/jwilliard/My Documen...
<?xml-stylesheet type='text/xsl' href='./as.xslt'?>";
---------------------------------------------------^
Generating XML with ASP
XML can be generated on a server without any installed XML software.
To generate an XML response from the server - simply write the following code and save it as an ASP file on the web server:
<%
response.ContentType="text/xml"
response.Write("<?xml version='1.0' encoding='ISO-8859-1'?>")
response.Write("<note>")
response.Write("<from>Jani</from>")
response.Write("<to>Tove</to>")
response.Write("<message>Remember me this weekend</message>")
response.Write("</note>")
%>
Note that the content type of the response must be set to "text/xml".
How do I set the content type in php? Is this my problem?
Thank you huge for any help.