How can I make a downloadable .xml file?

Shafizadeh

Here is my code:

public function xmlExport(){

    $xml = new \SimpleXMLElement('<xml/>');

    for ($i = 1; $i <= 8; ++$i) {
        $track = $xml->addChild('track');
        $track->addChild('path', "تست ");
        $track->addChild('title', "Track $i - Track Title");
    }

    Header('Content-type: text/xml');
    print($xml->asXML());
}

When I run code above, it prints something in the current browser page. But I want to make a .xml file of that which is downloadable .. Is doing that possible by PHP?

take

With the Content-Disposition: attachment header, you can force the browser to download your 'file'.

<?php
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="file.xml"');
xmlExport();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I put a downloadable file into the HttpServletResponse?

From Dev

How can i make my OS X application downloadable?

From Dev

How to make it as downloadable excel file using servlets

From Dev

How should I make files downloadable?

From Dev

How can I add a downloadable file to my Github.io page?

From Dev

How to correctly make a Wordpress plugin returns a downloadable excel file

From Dev

How to correctly make a Wordpress plugin returns a downloadable excel file

From Dev

How do I make an SVGSVGElement from paper.js downloadable?

From Dev

How do I make files downloadable for a particular role in Plone?

From Dev

How can I add php to an xml file using .htaccess and make it work?

From Dev

How to make a dynamic xml file that I can access through js with php

From Dev

How can I make the Views defined in Android XML customs view file visible

From Dev

How can I make an "appearance file" for NSAppearance?

From Dev

How can i make this calculations from file?

From Dev

How can I make a .jar file executable?

From Dev

How I can parse XML file with php

From Dev

How can I convert a CSV file to XML?

From Dev

How can i parse that xml file with jquery

From Dev

How can I setup ~/.tidyrc file for XML?

From Dev

How can I convert a CSV file to XML?

From Dev

How can I replace '&amp;' with '&' in XML file?

From Dev

How to make downloadable correct pdf file and verify it in itextsharp in asp.net?

From Dev

How can I make an autorun to make a program open a file automatically

From Dev

How to make pdf files downloadable in codeigniter

From Dev

How can I write at the top of an XML file with XML::Writer

From Dev

How do I make use of an xml file in node.js?

From Dev

How can I make Python's ElementTree enforce XML schema?

From Dev

How can I make constant variables in Javafx for XML files

From Dev

How can I make this SQL function that parses XML faster

Related Related

  1. 1

    How can I put a downloadable file into the HttpServletResponse?

  2. 2

    How can i make my OS X application downloadable?

  3. 3

    How to make it as downloadable excel file using servlets

  4. 4

    How should I make files downloadable?

  5. 5

    How can I add a downloadable file to my Github.io page?

  6. 6

    How to correctly make a Wordpress plugin returns a downloadable excel file

  7. 7

    How to correctly make a Wordpress plugin returns a downloadable excel file

  8. 8

    How do I make an SVGSVGElement from paper.js downloadable?

  9. 9

    How do I make files downloadable for a particular role in Plone?

  10. 10

    How can I add php to an xml file using .htaccess and make it work?

  11. 11

    How to make a dynamic xml file that I can access through js with php

  12. 12

    How can I make the Views defined in Android XML customs view file visible

  13. 13

    How can I make an "appearance file" for NSAppearance?

  14. 14

    How can i make this calculations from file?

  15. 15

    How can I make a .jar file executable?

  16. 16

    How I can parse XML file with php

  17. 17

    How can I convert a CSV file to XML?

  18. 18

    How can i parse that xml file with jquery

  19. 19

    How can I setup ~/.tidyrc file for XML?

  20. 20

    How can I convert a CSV file to XML?

  21. 21

    How can I replace '&amp;' with '&' in XML file?

  22. 22

    How to make downloadable correct pdf file and verify it in itextsharp in asp.net?

  23. 23

    How can I make an autorun to make a program open a file automatically

  24. 24

    How to make pdf files downloadable in codeigniter

  25. 25

    How can I write at the top of an XML file with XML::Writer

  26. 26

    How do I make use of an xml file in node.js?

  27. 27

    How can I make Python's ElementTree enforce XML schema?

  28. 28

    How can I make constant variables in Javafx for XML files

  29. 29

    How can I make this SQL function that parses XML faster

HotTag

Archive