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] Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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) Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 14, 2007 Share Posted March 14, 2007 echo '<'.'?'; monk.e.boy Quote Link to comment 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 Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.