The foreground implements the download XML function

Source: Internet
Author: User

Usually when we go through the href link file, the general situation is for the zip, jar and other download functions, and for XML, CSS, HTML, JS and so is the view function.

The following code can now generate a string in XML format to generate an XML file so that the XML file can be downloaded.

  

<! DOCTYPE html>"en">"UTF-8"> <title>Title</title>window.onload=function () {varHTML ='<a href= "Data:text/xml;charset=utf-8,'+ encodeURIComponent (text) +'"download=" > Downloads </a>'; Document.body.innerHTML=html; }    varText ='<?xml version= "1.0" encoding= "UTF-8" standalone= "yes"? >\<config-routing>                <array name="Private">                    <key name="Amount">3</key>                    <array name="Info">                        <key name="name"> Aston </key>                        <key name="ID">1</key>                    </array>                    <array name="Info">                        <key name="name"> Aston </key>                        <key name="ecu_id">2</key>                    </array>                    <array name="Info">                        <key name="name">3we</key>                        <key name="ID">3</key>                    </array>            </array>        </config_routing>';</script>

This will not have to pass data to the background, and then the background to assemble XML, and then to download XML, more efficient.

The foreground implements the download XML function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.