Cannot display grrek text taken from XML with Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikek12004
    New Member
    • Sep 2008
    • 200

    Cannot display grrek text taken from XML with Javascript

    I have an XML and I take from it some data with javascript and diplay them, when the data are in english all fine but when in greek it shows non-understadanble symbols, tried to change the charcet from the mata tag of the page but didn't work (after all when written in HTML the greek is shown just fine) in anonther occasion I overcome the problem with the PHP function iconv() is there something similar in Javascript? or I must do something in XML.

    PS not sure if I should post it in the javascript or XML section so I decided to post it here
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    How are you extracting the data from the XML file?

    Comment

    • mikek12004
      New Member
      • Sep 2008
      • 200

      #3
      through an API function of the JW PLAyer the entire code is here
      (you can get a working example at
      http://www.jeroenwijering.com/?page=wizard&example=24)
      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <title>Testing Title</title>
      <script type="text/javascript">
      var player = null;
      var currentItem = 0;
      
      function playerReady(obj)
      {
      player = gid(obj.id);
      player.addControllerListener('ITEM', 'itemMonitor');
      player.addModelListener('STATE', 'stateMonitor');
      };
      
      function itemMonitor(obj)
      {
      currentItem = obj.index;
      };
      
      function stateMonitor(obj)
      {
      //...get title
      if(obj.newstate == 'PLAYING')
      {
      gid('title').innerHTML = 'Title:' + player.getPlaylist()[currentItem]['title'];
      }
      }
      
      function gid(name)
      {
      return document.getElementById(name);
      };
      </script>
      </head>
      <body>
      <table>
      <tr>
      <td>
      <script type="text/javascript" src="swfobject.js"></script>
      <div id="player">This text will be replaced</div>
      
      <script type="text/javascript">
      var width=323;
      var height=267;
      var so = new SWFObject('player.swf','mpl','323','267','9');
      so.addParam('allowscriptaccess','always');
      so.addParam('allowfullscreen','true');
      so.addParam('flashvars','&file=asx.xml&autostart=true&repeat=list');
      so.write('player');
      </script>
      
      <div id="title"></div>
      </td>
      </tr>
      </table>
      </body>
      </html>
      The xml file is
      Code:
      <asx version="3.0" >
      	<title>General Music ASX playlist</title>
      	 
      	<moreinfo href="http://www.emile.com"/>
      
      	<entry>
      		<title>ασγ|1.00904.jpg</title>
      		<ref href="../player_files/videos/YouTube - 301 kai simera!(den antexw).flv" />
      		<moreinfo href="http://www.bigbuckbunny.org/" />
      	</entry>
      	<entry>
      		<title>a2</title>
      		<ref href="../player_files/videos/bunny.flv" />
      		<moreinfo href="http://www.bigbuckbunny.org/" />
      	</entry>
      	<entry>
      		<title>a3</title>
      		<ref href="../player_files/videos/YouTube - Alice Cooper - Poison.flv" />
      		<moreinfo href="http://www.bigbuckbunny.org/" />
      	</entry>
      
      	
      
      </asx>
      with the replaceHTML property I replace the contents of a div with the contents of the title tag of each song, since anywhere else even inside the javascript I can write greek, the problem is how to write them in the asx file I believe the problem lies there

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        This may well be a Flash problem. Perhaps there's an option that you set using SWFobject?

        Comment

        • mikek12004
          New Member
          • Sep 2008
          • 200

          #5
          OK solved, I added the <?phpxml version='1.0' encoding='UTF-8'?> which I thought to be wrong since I had <asx version="3.0" > no all is fine
          Thanks for your time

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Glad you got it working :)

            Comment

            Working...