I
I
isxaker2013-10-22 11:06:58
JavaScript
isxaker, 2013-10-22 11:06:58

How to open local xml file on android using javascript?

I have a local .html page with a button, when clicked, I want to open and parse a local .xml file in the android browser.
Tried to do it in two ways:
1)

load: function () {

        $.ajax({
            type: "GET",
            async: false,
            url: "structure.xml",
            data: {
                key: "value"
            },
            dataType: "xml",
            success: function (xmlDoc) {
                alert("success");
                Parser.currentNode = xmlDoc.documentElement;
                Parser.rootTagName = xmlDoc.documentElement.tagName;
                Util.pathLoadedFiles = xmlDoc.documentElement.getAttribute("path");
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus);
            }

        });
}

I get into error. (if I run it on Win in IE, everything works as it should)

2)
load: function () {

        xmlhttp = new XMLHttpRequest();
        xmlhttp.open("GET", "structure.xml", false);
        xmlhttp.send();
        xmlDoc = xmlhttp.responseXML;
        if (xmlDoc.readyState == 4) {
      Parser.currentNode = xmlDoc.documentElement;
      Parser.rootTagName = xmlDoc.documentElement.tagName;
      Util.pathLoadedFiles = xmlDoc.documentElement.getAttribute("path");
        }
    }

The same thing - it doesn’t work on android, but if I run it on Win in IE, everything works as it should

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2013-10-22
@rPman

This is a blatant violation of security, I consider the ability to open files locally from a web application (even running locally) a huge hole. Apparently, IE still sins with this (probably they made a bunch of plugs in the mail client so as not to be full of holes).
On mind it by the way is configured in politicians (for IE).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question