Why won't the android browser won't load and/or display my XML data?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • npm
    New Member
    • Apr 2007
    • 57

    Why won't the android browser won't load and/or display my XML data?

    I'm trying to find out why the android browser won't load and/or display my XML data. This javascript works fine on computer browsers (FF, IE, Safari, Chrome, Opera) and even in iPhone's Safari, but when I view the same page in my android's browser, nothing is displayed...it' s just blank. Is it a javascript bug in the android browser?

    Code:
    <html>
    <head>
    <script type="text/javascript">
      function loadXMLDoc(dname) {
        var xmlDoc;
        if (window.XMLHttpRequest) {
          xmlDoc = new window.XMLHttpRequest();
          xmlDoc.open("GET",dname,false);
          xmlDoc.send("");
          return xmlDoc.responseXML;
        }
        // IE 5 and IE 6
        else if (ActiveXObject("Microsoft.XMLDOM")) {
          xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
          xmlDoc.async=false;
          xmlDoc.load(dname);
          return xmlDoc;
        }
        alert("Error loading document");
        return null;
      }
    </script>
    </head>
    
    <body>
    <script type="text/javascript">
      xmlDoc = loadXMLDoc("news.xml");
      x = xmlDoc.getElementsByTagName('article');
      for (i=0; i<x.length; i++) {
        document.write("<span class='h2'>" + x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue + "</span><br />");
        document.write("<span class='gray'>" + x[i].getElementsByTagName("date")[0].childNodes[0].nodeValue + "</span><br /><br />");
        document.write(x[i].getElementsByTagName("text")[0].childNodes[0].nodeValue + "<hr />");
      }
    </script>
    </body>
    </html>
    I wasn't sure if this should be posted in "Mobile Development" or here in "Javascript/Ajax/DHTML" so here it is...but thanks anyway for any insight you may have!
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Not having an android myself or ever having to develop specifically for it, I would say your best bet is to find some developer docs for the android and find out what it supports and what it doesn't support and then go from there.

    Comment

    Working...