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

Cannot display grrek text taken from XML with Javascript

mikek12004
100+
P: 200
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
Oct 17 '08 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
How are you extracting the data from the XML file?
Oct 17 '08 #2

mikek12004
100+
P: 200
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)
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.  
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Testing Title</title>
  7. <script type="text/javascript">
  8. var player = null;
  9. var currentItem = 0;
  10.  
  11. function playerReady(obj)
  12. {
  13. player = gid(obj.id);
  14. player.addControllerListener('ITEM', 'itemMonitor');
  15. player.addModelListener('STATE', 'stateMonitor');
  16. };
  17.  
  18. function itemMonitor(obj)
  19. {
  20. currentItem = obj.index;
  21. };
  22.  
  23. function stateMonitor(obj)
  24. {
  25. //...get title
  26. if(obj.newstate == 'PLAYING')
  27. {
  28. gid('title').innerHTML = 'Title:' + player.getPlaylist()[currentItem]['title'];
  29. }
  30. }
  31.  
  32. function gid(name)
  33. {
  34. return document.getElementById(name);
  35. };
  36. </script>
  37. </head>
  38. <body>
  39. <table>
  40. <tr>
  41. <td>
  42. <script type="text/javascript" src="swfobject.js"></script>
  43. <div id="player">This text will be replaced</div>
  44.  
  45. <script type="text/javascript">
  46. var width=323;
  47. var height=267;
  48. var so = new SWFObject('player.swf','mpl','323','267','9');
  49. so.addParam('allowscriptaccess','always');
  50. so.addParam('allowfullscreen','true');
  51. so.addParam('flashvars','&file=asx.xml&autostart=true&repeat=list');
  52. so.write('player');
  53. </script>
  54.  
  55. <div id="title"></div>
  56. </td>
  57. </tr>
  58. </table>
  59. </body>
  60. </html>
  61.  
The xml file is
Expand|Select|Wrap|Line Numbers
  1. <asx version="3.0" >
  2.     <title>General Music ASX playlist</title>
  3.  
  4.     <moreinfo href="http://www.emile.com"/>
  5.  
  6.     <entry>
  7.         <title>ασγ|1.00904.jpg</title>
  8.         <ref href="../player_files/videos/YouTube - 301 kai simera!(den antexw).flv" />
  9.         <moreinfo href="http://www.bigbuckbunny.org/" />
  10.     </entry>
  11.     <entry>
  12.         <title>a2</title>
  13.         <ref href="../player_files/videos/bunny.flv" />
  14.         <moreinfo href="http://www.bigbuckbunny.org/" />
  15.     </entry>
  16.     <entry>
  17.         <title>a3</title>
  18.         <ref href="../player_files/videos/YouTube - Alice Cooper - Poison.flv" />
  19.         <moreinfo href="http://www.bigbuckbunny.org/" />
  20.     </entry>
  21.  
  22.  
  23.  
  24. </asx>
  25.  
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
Oct 17 '08 #3

acoder
Expert Mod 15k+
P: 16,027
This may well be a Flash problem. Perhaps there's an option that you set using SWFobject?
Oct 17 '08 #4

mikek12004
100+
P: 200
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
Oct 17 '08 #5

acoder
Expert Mod 15k+
P: 16,027
Glad you got it working :)
Oct 17 '08 #6

Post your reply

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