×

Discussion Board

Results 1 to 2 of 2

Thread: call local xml

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    5

    call local xml

    Code:
    function xmlload(){
    var xmlDOM = new ActiveXObject("Microsoft.XMLDOM");
    	 xmlDOM.async = false;
    	 xmlf = "./main.xml";
    	 xmlDOM.load(xmlf);
    	 
    	 var xmlHttp;
    
    var xmlTag_A = xmlDOM.getElementsByTagName("Mon");
    for (var i = 0; i < 10; i++) {
    				xv0 = xmlTag_A[0].childNodes[i].childNodes[0].childNodes[0].nodeValue;
    				xv1 = xmlTag_A[0].childNodes[i].childNodes[1].childNodes[0].nodeValue;
    				xv2 = xmlTag_A[0].childNodes[i].childNodes[2].childNodes[0].nodeValue;
    				var ss = "A" + i;
    				document.getElementById(ss).innerHTML = xv0 + "<br>" + xv1 + "<br>" + xv2;
    			}
    }
    Code:
    <?xml version="1.0" encoding="utf-8"?>
     <Schedule>
     	<Mon>
     	 <Period>
     		<Study>A1</Study>
    		<Classroom>A1</Classroom>
    		<Professor>A1</Professor>
    	 </Period>
         <Period>
     		<Study>A2</Study>
    		<Classroom>A2</Classroom>
    		<Professor>A2</Professor>
    	 </Period>
    	 <Period>
     		<Study>A3</Study>
    		<Classroom>A3</Classroom>
    		<Professor>A3</Professor>
    	 </Period>
    	 <Period>
     		<Study>A4</Study>
    		<Classroom>A4</Classroom>
    		<Professor>A4</Professor>
    	 </Period>
    	 <Period>
     		<Study>A5</Study>
    		<Classroom>A5</Classroom>
    		<Professor>A5</Professor>
    	 </Period>
    	 <Period>
     		<Study>A6</Study>
    		<Classrooms>A6</Classrooms>
    		<Professor>A6</Professor>
    	 </Period>
         <Period>
     		<Study>A7</Study>
    		<Classroom>A7</Classroom>
    	 	<Professor>A7</Professor>
    	 </Period>
    	 <Period>
     		<Study>A8</Study>
    		<Classroom>A8</Classroom>
    		<Professor>A8</Professor>
    	 </Period>
    	 <Period>
     		<Study>A9</Study>
    		<Classroom>A9</Classroom>
    		<Professor>A9</Professor>
    	 </Period>
    	 <Period>
     		<Study>A10</Study>
    		<Classroom>A10</Classroom>
    		<Professor>A10</Professor>
    	 </Period>
    </Mon>
    </Schedule>
    I used to this source..
    but I realized this isn't working on nokia..
    How can I change this source using XMLHttpRequest..
    I have no idea..
    please give me some sample..

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    5

    Re: call local xml

    I found an example

    Code:
    <html>
    <head>
    <script type="text/javascript">
    var xmlhttp;
    
    function loadXMLDoc(url)
    {
    xmlhttp=null;
    if (window.XMLHttpRequest)
      {// code for IE7, Firefox, Mozilla, etc.
      xmlhttp=new XMLHttpRequest();
      }
    else if (window.ActiveXObject)
      {// code for IE5, IE6
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    if (xmlhttp!=null)
      {
      xmlhttp.onreadystatechange=onResponse;
      xmlhttp.open("GET",url,true);
      xmlhttp.send(null);
      }
    else
      {
      alert("Your browser does not support XMLHTTP.");
      }
    }
    
    function onResponse()
    {
    if(xmlhttp.readyState!=4) return;
    if(xmlhttp.status!=200)
      {
      alert("Problem retrieving XML data");
      return;
      }
    
    txt="<table border='1'>";
    x=xmlhttp.responseXML.documentElement.getElementsByTagName("CD");
    for (i=0;i<x.length;i++)
      {
      txt=txt + "<tr>";
      xx=x[i].getElementsByTagName("TITLE");
        {
        try
          {
          txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
          }
        catch (er)
          {
          txt=txt + "<td> </td>";
          }
        }
      xx=x[i].getElementsByTagName("ARTIST");
        {
        try
          {
          txt=txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
          }
        catch (er)
          {
          txt=txt + "<td> </td>";
          }
        }
      txt=txt + "</tr>";
      }
    txt=txt + "</table>";
    document.getElementById('copy').innerHTML=txt;
    }
    
    </script>
    </head>
    
    <body>
    <div id="copy">
    <button onclick="loadXMLDoc('cd_catalog.xml')">Get CD info</button>
    </div>
    </body>
    </html>
    Code:
    <?xml version="1.0"?>
    <!-- Edited by XMLSpy® -->
    <CATALOG>
      <CD>
        <TITLE>Empire Burlesque</TITLE>
        <ARTIST>Bob Dylan</ARTIST>
        <COUNTRY>USA</COUNTRY>
        <COMPANY>Columbia</COMPANY>
        <PRICE>10.90</PRICE>
        <YEAR>1985</YEAR>
      </CD>
      <CD>
        <TITLE>Hide your heart</TITLE>
        <ARTIST>Bonnie Tyler</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>CBS Records</COMPANY>
        <PRICE>9.90</PRICE>
        <YEAR>1988</YEAR>
      </CD>
      <CD>
        <TITLE>Greatest Hits</TITLE>
        <ARTIST>Dolly Parton</ARTIST>
        <COUNTRY>USA</COUNTRY>
        <COMPANY>RCA</COMPANY>
        <PRICE>9.90</PRICE>
        <YEAR>1982</YEAR>
      </CD>
      <CD>
        <TITLE>Still got the blues</TITLE>
        <ARTIST>Gary More</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>Virgin redords</COMPANY>
        <PRICE>10.20</PRICE>
        <YEAR>1990</YEAR>
      </CD>
      <CD>
        <TITLE>Eros</TITLE>
        <ARTIST>Eros Ramazzotti</ARTIST>
        <COUNTRY>EU</COUNTRY>
        <COMPANY>BMG</COMPANY>
        <PRICE>9.90</PRICE>
        <YEAR>1997</YEAR>
      </CD>
      <CD>
        <TITLE>One night only</TITLE>
        <ARTIST>Bee Gees</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>Polydor</COMPANY>
        <PRICE>10.90</PRICE>
        <YEAR>1998</YEAR>
      </CD>
      <CD>
        <TITLE>Sylvias Mother</TITLE>
        <ARTIST>Dr.Hook</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>CBS</COMPANY>
        <PRICE>8.10</PRICE>
        <YEAR>1973</YEAR>
      </CD>
      <CD>
        <TITLE>Maggie May</TITLE>
        <ARTIST>Rod Stewart</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>Pickwick</COMPANY>
        <PRICE>8.50</PRICE>
        <YEAR>1990</YEAR>
      </CD>
      <CD>
        <TITLE>Romanza</TITLE>
        <ARTIST>Andrea Bocelli</ARTIST>
        <COUNTRY>EU</COUNTRY>
        <COMPANY>Polydor</COMPANY>
        <PRICE>10.80</PRICE>
        <YEAR>1996</YEAR>
      </CD>
      <CD>
        <TITLE>When a man loves a woman</TITLE>
        <ARTIST>Percy Sledge</ARTIST>
        <COUNTRY>USA</COUNTRY>
        <COMPANY>Atlantic</COMPANY>
        <PRICE>8.70</PRICE>
        <YEAR>1987</YEAR>
      </CD>
      <CD>
        <TITLE>Black angel</TITLE>
        <ARTIST>Savage Rose</ARTIST>
        <COUNTRY>EU</COUNTRY>
        <COMPANY>Mega</COMPANY>
        <PRICE>10.90</PRICE>
        <YEAR>1995</YEAR>
      </CD>
      <CD>
        <TITLE>1999 Grammy Nominees</TITLE>
        <ARTIST>Many</ARTIST>
        <COUNTRY>USA</COUNTRY>
        <COMPANY>Grammy</COMPANY>
        <PRICE>10.20</PRICE>
        <YEAR>1999</YEAR>
      </CD>
      <CD>
        <TITLE>For the good times</TITLE>
        <ARTIST>Kenny Rogers</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>Mucik Master</COMPANY>
        <PRICE>8.70</PRICE>
        <YEAR>1995</YEAR>
      </CD>
      <CD>
        <TITLE>Big Willie style</TITLE>
        <ARTIST>Will Smith</ARTIST>
        <COUNTRY>USA</COUNTRY>
        <COMPANY>Columbia</COMPANY>
        <PRICE>9.90</PRICE>
        <YEAR>1997</YEAR>
      </CD>
      <CD>
        <TITLE>Tupelo Honey</TITLE>
        <ARTIST>Van Morrison</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>Polydor</COMPANY>
        <PRICE>8.20</PRICE>
        <YEAR>1971</YEAR>
      </CD>
      <CD>
        <TITLE>Soulsville</TITLE>
        <ARTIST>Jorn Hoel</ARTIST>
        <COUNTRY>Norway</COUNTRY>
        <COMPANY>WEA</COMPANY>
        <PRICE>7.90</PRICE>
        <YEAR>1996</YEAR>
      </CD>
      <CD>
        <TITLE>The very best of</TITLE>
        <ARTIST>Cat Stevens</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>Island</COMPANY>
        <PRICE>8.90</PRICE>
        <YEAR>1990</YEAR>
      </CD>
      <CD>
        <TITLE>Stop</TITLE>
        <ARTIST>Sam Brown</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>A and M</COMPANY>
        <PRICE>8.90</PRICE>
        <YEAR>1988</YEAR>
      </CD>
      <CD>
        <TITLE>Bridge of Spies</TITLE>
        <ARTIST>T`Pau</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>Siren</COMPANY>
        <PRICE>7.90</PRICE>
        <YEAR>1987</YEAR>
      </CD>
      <CD>
        <TITLE>Private Dancer</TITLE>
        <ARTIST>Tina Turner</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>Capitol</COMPANY>
        <PRICE>8.90</PRICE>
        <YEAR>1983</YEAR>
      </CD>
      <CD>
        <TITLE>Midt om natten</TITLE>
        <ARTIST>Kim Larsen</ARTIST>
        <COUNTRY>EU</COUNTRY>
        <COMPANY>Medley</COMPANY>
        <PRICE>7.80</PRICE>
        <YEAR>1983</YEAR>
      </CD>
      <CD>
        <TITLE>Pavarotti Gala Concert</TITLE>
        <ARTIST>Luciano Pavarotti</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>DECCA</COMPANY>
        <PRICE>9.90</PRICE>
        <YEAR>1991</YEAR>
      </CD>
      <CD>
        <TITLE>The dock of the bay</TITLE>
        <ARTIST>Otis Redding</ARTIST>
        <COUNTRY>USA</COUNTRY>
        <COMPANY>Atlantic</COMPANY>
        <PRICE>7.90</PRICE>
        <YEAR>1987</YEAR>
      </CD>
      <CD>
        <TITLE>Picture book</TITLE>
        <ARTIST>Simply Red</ARTIST>
        <COUNTRY>EU</COUNTRY>
        <COMPANY>Elektra</COMPANY>
        <PRICE>7.20</PRICE>
        <YEAR>1985</YEAR>
      </CD>
      <CD>
        <TITLE>Red</TITLE>
        <ARTIST>The Communards</ARTIST>
        <COUNTRY>UK</COUNTRY>
        <COMPANY>London</COMPANY>
        <PRICE>7.80</PRICE>
        <YEAR>1987</YEAR>
      </CD>
      <CD>
        <TITLE>Unchain my heart</TITLE>
        <ARTIST>Joe Cocker</ARTIST>
        <COUNTRY>USA</COUNTRY>
        <COMPANY>EMI</COMPANY>
        <PRICE>8.20</PRICE>
        <YEAR>1987</YEAR>
      </CD>
    </CATALOG>
    It doesn't work on WRT !
    When I click the button
    It says 'Problem retrieving XML data'...

    http://www.w3schools.com/dom/tryit.a...ttprequest_js4

    what's wrong with this source
    I thought s60 support XMLHttpRequest .. doesn't it?

Similar Threads

  1. Active call from CTelephony vanishes on E52
    By kisaki in forum Symbian
    Replies: 0
    Last Post: 2009-10-30, 14:08
  2. Replies: 6
    Last Post: 2009-09-02, 09:48
  3. Replies: 5
    Last Post: 2009-08-26, 09:36
  4. End call and DialNewCall problems
    By halimz in forum Symbian
    Replies: 5
    Last Post: 2007-05-19, 05:40
  5. Local xml provisioning
    By Orakel78 in forum Symbian
    Replies: 1
    Last Post: 2007-01-26, 09:45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×