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
https://forums.phpfreaks.com/topic/42615-solved-using-php-to-generate-a-xml-file/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.