Can a JavaScript written on HTML page get info from XML?

riddrelasurp

New Member
Lets say i have this javascript code in an html pages\[code\]<script type="text/javascript">$(document).ready(function(){ $('.info2').CreateBubblePopup({ position : 'left', align : 'center',innerHtml: 'some text ',innerHtmlStyle: { color:'#FFFFFF', 'text align':'center' },themeName: 'all-black',themePath: 'images/jquerybubblepopup-themes' }); }); </script> \[/code\]I want to make this script get the "info2" and the "some test" from the xml files i have in which i added a tag for "info2" called <-INFOID-> and a tag for "some text" called "<-INFODATA-> (without the -, just added them coz the tags where disappearing)so i used this code below to connect the xml and to write the script\[code\]<script type="text/javascript">if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.open("GET","scores.xml",false);xmlhttp.send();xmlDoc=xmlhttp.responseXML; document.write("<script type='text/javascript'>");var x=xmlDoc.getElementsByTagName("GAME");for (i=0;i<x.length;i++) { document.write("$(document).ready(function(){ $('."); document.write(x.getElementsByTagName("INFOID")[0].childNodes[0].nodeValue); document.write("').CreateBubblePopup({ position : 'left', align : 'center',"); document.write("innerHtml: '"); document.write(x.getElementsByTagName("INFODATA")[0].childNodes[0].nodeValue); document.write("',"); document.write("innerHtmlStyle: { color:'#FFFFFF', 'text-align':'center' },"); document.write("themeName: 'all-black',"); document.write("themePath: 'images/jquerybubblepopup-themes' }); });"); }document.write("</script>");</script> \[/code\]I have no idea if XML works in Javascript i was just giving it a try but it didnt workso does xml work with javascript? if yes what is wrong in my code?My scores.xml file looks :\[code\]<SCORES><GAME><DATE>14.5.2012 12:05</DATE><TIME>FT</TIME><HOMETEAM>Team1</HOMETEAM><SCORE>4 - 0</SCORE><AWAYTEAM>Team2</AWAYTEAM><OTHER> </OTHER><INFO><![CDATA[<img class='info1' src='http://stackoverflow.com/questions/10581572/images/info.png' width='14px' height='14px' border='0' />]]></INFO><INFOID>info1</INFOID><INFODATA>FIRST BUBBLE</INFODATA></GAME><GAME><DATE>14.5.2012 12:05</DATE><TIME>FT</TIME><HOMETEAM>Team3</HOMETEAM><SCORE>2 - 0</SCORE><AWAYTEAM>Team4</AWAYTEAM><OTHER> </OTHER><INFO><![CDATA[<img class='info2' src='http://stackoverflow.com/questions/10581572/images/info.png' width='14px' height='14px' border='0' />]]></INFO><INFOID>info2</INFOID><INFODATA>SECOND BUBBLE</INFODATA></GAME></SCORES>\[/code\]the other tags i used them in the page...the last 2 tags are to configure this script which is a pop up bubble for a lil img
 
Back
Top