Jump to content

[SOLVED] Using php to generate a .xml file


Azu

Recommended Posts

I have a .xml file which normally looks fine, type is text/html

 

The problem is, when I make the .xml file be parsed with PHP, and I put in the header at the start, and all I do is echo what was there before, it totally ruins it it basically turns it into a plain .txt file

 

Why is it doing this? Please tell me how to fix x_x this is very frustrating

 

It should be exactly the same...

 

Basically it is like this

 

before

blah blah[/url]
after[code]<?header; echo blah blah;?>

So ya it should be exactly the same but instead it is totally ruining it please help =\[/code]

Link to comment
Share on other sites

Not too sure that this is what you mean but this is how I generate dynamic XML from a php page:

 

<?php
$xml =<<<XML
<?xml version="1.0" encoding="utf-8"?>
<products>
  <product>
     <name>Some Product</name>
     <name>1.99</name>
  </product>
</products>
XML;

print ($xml);

header( "Content-type: application/xml; charset=\"iso-8859-1\", true");
header("Pragma: no-cache");
?>

 

The XML would likely come from a database.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.