Azu Posted March 14, 2007 Share Posted March 14, 2007 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 More sharing options...
monk.e.boy Posted March 14, 2007 Share Posted March 14, 2007 xml is text/xml or plain old text, not text/html. I'm not sure what your question is? monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42615-solved-using-php-to-generate-a-xml-file/#findComment-206891 Share on other sites More sharing options...
mbtaylor Posted March 14, 2007 Share Posted March 14, 2007 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 https://forums.phpfreaks.com/topic/42615-solved-using-php-to-generate-a-xml-file/#findComment-206915 Share on other sites More sharing options...
Lumio Posted March 14, 2007 Share Posted March 14, 2007 I also got a question: how can I use <?xml version="1.0" encoding="utf-8"?> without getting php-problems? Link to comment https://forums.phpfreaks.com/topic/42615-solved-using-php-to-generate-a-xml-file/#findComment-206920 Share on other sites More sharing options...
mbtaylor Posted March 14, 2007 Share Posted March 14, 2007 because the <? is contained in a string. Check out HEREDOC syntax in the php manual (explained in the print manual page) Link to comment https://forums.phpfreaks.com/topic/42615-solved-using-php-to-generate-a-xml-file/#findComment-206921 Share on other sites More sharing options...
monk.e.boy Posted March 14, 2007 Share Posted March 14, 2007 echo '<'.'?'; monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42615-solved-using-php-to-generate-a-xml-file/#findComment-206951 Share on other sites More sharing options...
Lumio Posted March 14, 2007 Share Posted March 14, 2007 mbtaylor... I know monk.e.boy ... I didn't thought about that... thanks Link to comment https://forums.phpfreaks.com/topic/42615-solved-using-php-to-generate-a-xml-file/#findComment-207027 Share on other sites More sharing options...
Azu Posted March 15, 2007 Author Share Posted March 15, 2007 Oh you were right about the header lol I had it wrong.. fixed it and now it's working perfectly! Thanks everyone! Link to comment https://forums.phpfreaks.com/topic/42615-solved-using-php-to-generate-a-xml-file/#findComment-207636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.