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

Why won't the android browser load/display xml?

P: 57
I'm trying to find out why the android browser won't load and/or display my XML data. It 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.

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>
Any ideas?
Thanks in advance!!!
Dec 2 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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