简体   繁体   English

从URL下载xml文件进行解析

[英]Download xml file from URL to parse

I want to develop an app that parses an XML file. 我想开发一个解析XML文件的应用程序。 The file downloads when one navigates to a certain webpage. 当人们导航到某个网页时,文件下载。 However, the xml file is not a part of the URL. 但是,xml文件不是URL的一部分。

Therefore, when I tried making a webapp and used jquery and ajax to try and download it, it didn't work. 因此,当我尝试制作一个Web应用程序并使用jquery和ajax尝试下载它时,它不起作用。 I found a solution to patch the cross domain issue using yql, but since the file is not a part of the path, it didn't work. 我找到了一种使用yql修补跨域问题的解决方案,但是由于该文件不是路径的一部分,因此无法正常工作。

Is there a way I can possible develop a Java applet to download the file even though its not a part of the URL? 有没有办法开发Java小程序来下载文件,即使它不是URL的一部分?

Or can I stick to web development? 还是我可以坚持进行Web开发?

Just need some guidance. 只需要一些指导。

The URL looks something like this: URL看起来像这样:

https://sales.blablabla.net/qx/web/login/utilities/tixExport.jsp?&site=49151746&user=john&pass=doe&tid=ZYX2034982309482x https://sales.blablabla.net/qx/web/login/utilities/tixExport.jsp?&site=49151746&user=john&pass=doe&tid=ZYX2034982309482x

I would do it on the server side using cURL if possible. 如果可能,我会在服务器端使用cURL进行操作。 If your using PHP this example would work. 如果您使用的是PHP,则此示例有效。

<?php 
        // create curl resource 
        $ch = curl_init(); 

        // set url 
        curl_setopt($ch, CURLOPT_URL, "example.com"); 

        //return the transfer as a string 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

        // $output contains the output string 
        $output = curl_exec($ch); 

        // close curl resource to free up system resources 
            curl_close($ch); 

        // output XML to page
          header('Content-Type: text/xml');
          echo $output;
    ?>

You would use a jQuery AJAX request to pull in that PHP file. 您将使用jQuery AJAX请求引入该PHP文件。

I think you must do it server side for this to work. 我认为您必须在服务器端完成此工作。 U can download the file in the controller and serve it there like a stream. 您可以将文件下载到控制器中,然后像流一样将其提供给控制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM