michaelfurey Posted August 10, 2017 Share Posted August 10, 2017 I have to generate the following text with a php script in the server and render it in chrome, then copy it manually with the mouse and finally paste it manually in a xml file located in my desktop pc. The text is the following: <?xml version="1.0" encoding="UTF-8"?> <shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="shiporder.xsd"> <orderperson>John Smith</orderperson> <item> <title>Hide your heart</title> <quantity>1</quantity> <price>9.90</price> </item> <item> <title>Hide your heart</title> <quantity>1</quantity> <price>9.90</price> </item> </shiporder> The problem is that I have to render in the browser also the tags and the text included inside the tags... is it possible to render that text in chrome in that way? Quote Link to comment Share on other sites More sharing options...
kicken Posted August 10, 2017 Share Posted August 10, 2017 If you want to display the XML rather than have chrome try to interpret it then run it through htmlspecialchars prior to displaying it. echo '<p>The HTML code is:</p>'; echo '<code>' . htmlscpecialchars($xml) . '</code>'; Quote Link to comment Share on other sites More sharing options...
requinix Posted August 10, 2017 Share Posted August 10, 2017 view-source:http://domain.tld/path/to/script.phpOr make the script force a download instead of showing it in the browser. Or run PHP on your own computer and have it generate the file directly in the place you want. Or one of a bunch of other things. Quote Link to comment Share on other sites More sharing options...
michaelfurey Posted August 11, 2017 Author Share Posted August 11, 2017 If you want to display the XML rather than have chrome try to interpret it then run it through htmlspecialchars prior to displaying it. echo '<p>The HTML code is:</p>'; echo '<code>' . htmlscpecialchars($xml) . '</code>'; Ok perfect that I wanted to know! I apreciated also the test that you created for me to check if I have some problem solving skills ( " htmlsCpecialchars($xml) " ). Quote Link to comment Share on other sites More sharing options...
michaelfurey Posted August 11, 2017 Author Share Posted August 11, 2017 view-source:http://domain.tld/path/to/script.phpOr make the script force a download instead of showing it in the browser. Or run PHP on your own computer and have it generate the file directly in the place you want. Or one of a bunch of other things. Is it possible to download the output of the previous code from the server to the client? In that way I should obtain the xml content in the client without copying and paste through the browser. In other words I would like to run a file located in the server that generates the xml file and to download it authomatically to the client. Quote Link to comment Share on other sites More sharing options...
requinix Posted August 11, 2017 Share Posted August 11, 2017 The most you can do is have the browser start downloading the content but you cannot choose where it downloads to. Before any output, header('Content-Disposition: attachment; filename="whatever name you want.xml"'); 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.