469,898 Members | 1,734 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

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

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
1 2894
JKing
1,206 Expert 1GB
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.

Similar topics

2 posts views Thread by Alex Lee | last post: by
1 post views Thread by ebramcity | last post: by
8 posts views Thread by wpelgrum | last post: by
1 post views Thread by sreedhardasi | last post: by
3 posts views Thread by goldenv | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.