By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,106 Members | 2,679 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,106 IT Pros & Developers. It's quick & easy.

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

P: 57
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?

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.   function loadXMLDoc(dname) {
  5.     var xmlDoc;
  6.     if (window.XMLHttpRequest) {
  7.       xmlDoc = new window.XMLHttpRequest();
  8.       xmlDoc.open("GET",dname,false);
  9.       xmlDoc.send("");
  10.       return xmlDoc.responseXML;
  11.     }
  12.     // IE 5 and IE 6
  13.     else if (ActiveXObject("Microsoft.XMLDOM")) {
  14.       xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  15.       xmlDoc.async=false;
  16.       xmlDoc.load(dname);
  17.       return xmlDoc;
  18.     }
  19.     alert("Error loading document");
  20.     return null;
  21.   }
  22. </script>
  23. </head>
  24.  
  25. <body>
  26. <script type="text/javascript">
  27.   xmlDoc = loadXMLDoc("news.xml");
  28.   x = xmlDoc.getElementsByTagName('article');
  29.   for (i=0; i<x.length; i++) {
  30.     document.write("<span class='h2'>" + x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue + "</span><br />");
  31.     document.write("<span class='gray'>" + x[i].getElementsByTagName("date")[0].childNodes[0].nodeValue + "</span><br /><br />");
  32.     document.write(x[i].getElementsByTagName("text")[0].childNodes[0].nodeValue + "<hr />");
  33.   }
  34. </script>
  35. </body>
  36. </html>
  37.  
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!
Jan 26 '11 #1
Share this Question
Share on Google+
1 Reply


JKing
Expert 100+
P: 1,206
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.
Jan 26 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.