Jump to content

Using RegExp in JS to test an XML file


Johnshellshock

Recommended Posts

What exactly is this line for:document.getElementById("myTable").responseText;??responseText is the property of an XMLHttpRequest object that holds whatever response the server sent back. It has nothing to do with the DOM.My guess is that you should replace that line with:document.getElementById("myTable").appendChild(oTable);But to specifically answer your question:If myTable is a reference to the div where you want to insert the table then yes that is the correct syntax. Just put it after you have created the table and inserted all the rows and cells.

Link to comment
Share on other sites

The line you refer to is my first attempt to append the table to mytable in the body of the page.Yes I know now it looks silly but I was stuck.I replaced it with the code you suggested and am now getting the header output on the page in response to a valid match.document.getElementById("myTable").appendChild(oTable);The next thing for me to do is to get the style the same as my exisiting table and then start adding the tbody element.I will let you know how I get along as I am sure I will run in to yet more snags of my own misunderstanding.

Link to comment
Share on other sites

I have managed to add the body elements to the table and also stlye it so that it looks how I want it to look.I had to modify the Input form and put inside a div container so as to use css to style it but it seems to work as it should

<div id="artistsearch" align="center"><form name="myform" action="" onsubmit="Inputfromform(this);return false" method="GET">Search By Artist <input type="text" name="inputbox" value="" class="searchboxtext30" size="40" maxlength="30" /><input type="submit" name="button" value="Submit" class="button"/></form></div>

Below is the current JS

<script type="text/javascript">function loadXMLDoc(url,cfunc){if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.onreadystatechange=cfunc;xmlhttp.open("GET",url,true);xmlhttp.send();}function Inputfromform(form){            { document.getElementById("tabletrack").style.display = "none";             } 				//{//location.reload();   // }		     {    var TestVar=form.inputbox.value;           }	 	 //code to eliminate space as a input	 	 if (TestVar=="")	                  {                      loadXMLDoc("Text.txt",function()                              {                        if (xmlhttp.readyState==4 && xmlhttp.status==200)                                 {                      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;                                 }	                              });                                            }		          	 else  {	//code to evaluate form.inputbox.value which should give either a "true" or "false" result var TestVar2=new RegExp(TestVar,"i");       {loadXMLDoc("XMLData.xml",function()         {   if (xmlhttp.readyState==4 && xmlhttp.status==200)            {      var xmlDoc=xmlhttp.responseXML;      var x=xmlDoc.getElementsByTagName("track");	 	       var trackValue;	  var flag=false;      for (var i=0;i<x.length;i++)                {         trackValue = (x[i].getElementsByTagName("artist")[0].childNodes[0].nodeValue);			   		 	if (TestVar2.test(trackValue) == true)			                    {			 flag=true;	           // alert ("You Have A Match That is True: " + trackValue + flag + i );				                            {     			//Declare variables and create table, tableheader and tablebody			var oTable=document.createElement("table");			var oThead=document.createElement("thead");				var oTbody=document.createElement("tbody");			//var oRow,oCell;			//var i,j;						//Set the table's width and color			oTable.style.width = '926px';            oTable.style.backgroundColor='#c0c0c0';								              {			//Declare Table Headings			var heading = new Array();			heading[0] = "Track";			heading[1] = "Song Title";			heading[2] = "Artist";			heading[3] = "Key";			heading[4] = "Buy Now";			heading[5] = "View Cart";							            			//Insert the created elements into header			oTable.appendChild(oThead);									//Insert a row into the header and set its background color			oRow=document.createElement("tr");			oRow.style.height= '28px'			oRow.style.backgroundColor='#a8a8a8';			oRow.style.borderCollapse="collapse";			oRow.style.border = '4px solid #a8a8a8';			oThead.appendChild(oRow);			oThead.style.width = '926px';				    //Create and insert cells into the header Row								{			oCell=document.createElement("th");			oCell.innerHTML=heading[0];			oCell.style.width = '67px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[1];			oCell.style.width = '399px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[2];			oCell.style.width = '163px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[3];			oCell.style.width = '29px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[4];			oCell.style.width = '121px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[5];			oCell.style.width = '107px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}									              			               }			var x=xmlDoc.getElementsByTagName("track");			var trackValue;			     			for (var i=0;i<x.length;i++) 			              {			 trackValue = (x[i].getElementsByTagName("artist")[0].childNodes[0].nodeValue);			   		 	if (TestVar2.test(trackValue) == true)			         {  			  			//Insert the created elements into body			oTable.appendChild(oTbody);						//Insert a row into the body and set its background color			oRow1=document.createElement("tr");						oRow1.style.height= '28px';			oRow1.style.backgroundColor='#d8d8d8';			oRow1.style.borderCollapse="collapse";			oRow1.style.border = '4px solid #a8a8a8';			oTbody.appendChild(oRow1);									//Create and insert cells into the body Row						{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("number")[0].childNodes[0].nodeValue);						oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";						oData.style.fontWeight="bold";			oData.style.textAlign="center";			oData.style.width = '67px';			oData.className = 'style4';			oRow1.appendChild(oData);						}					    {			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.fontWeight="bold";			oData.style.textAlign="left";						oData.style.width = '399px';			oData.className = 'style4';			oRow1.appendChild(oData);			}		 			{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("artist")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.fontWeight="bold";			oData.style.textAlign="left";						oData.style.width = '163px';			oData.className = 'style4';			oRow1.appendChild(oData);			}						{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("key")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.fontWeight="bold";			oData.style.textAlign="center";			oData.style.width = '29px';			oData.className = 'style4';			oRow1.appendChild(oData);			}			{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("buy")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.width = '121px';			oData.className = 'style4';			oRow1.appendChild(oData);			}		    {			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("view")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.width = '107px';			oData.className = 'style4';			oRow1.appendChild(oData);			}			          }								                            }                             document.getElementById("myTable").appendChild(oTable);			                         }			                    }			                       }		 if (flag==false)//Fail Message Code      		                  {                      loadXMLDoc("Text.txt",function()                              {                        if (xmlhttp.readyState==4 && xmlhttp.status==200)                                 {				      //alert (flag);			                      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;					                                   }	                              });                                            }		  	               }         });       }    }                              		         	    }</script>

You can see it hearhttp://www.shellshockmusic.co.uk/search131.htmlI have noticed that when I get a match a table as required is writen but if I hit submit again with the same or differnt value a new table is writen just below the existing table whilst in the case of the fail message no matter how many times I hit the submitt button I only get one fail message. Why is this so as what I want is for each time I hit submit is for a fresh page to be displayed. I have played around with location.reload(); and have not been able to get it to work in a way that I expect.

Link to comment
Share on other sites

You want a fresh page? Then why are you using AJAX? Am I confused?
I have got round it by having a refresh button alongside the submit button. I have now added just over 100 tracks in to my xml file created 2 js files one for search by artist and the other for search by songThe input section
<div id="artistsearch" align="center"><form name="myform" action="" onsubmit="Inputfromform(this);return false" method="GET">Search By Artist <input type="text" name="inputbox" value="" class="searchboxtext30" size="40" maxlength="30" /><input type="submit" name="button" value="Submit" class="button"/><input type="button" onclick="history.go(0)" value="Refresh" class="button"/></form></div><br/><div id="artistsearch" align="center"><form name="myform" action="" onsubmit="Song(this);return false" method="GET">Search By Song <input type="text" name="inputbox" value="" class="searchboxtext30" size="40" maxlength="30" /><input type="submit" name="button" value="Submit" class="button"/><input type="button" onclick="history.go(0)" value="Refresh" class="button"/></form></div>

The js ref in header of page

<script type="text/javascript" src="artist.js"></script><script type="text/javascript" src="song.js"></script>

artist.js

// Java Documentfunction loadXMLDoc(url,cfunc){if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.onreadystatechange=cfunc;xmlhttp.open("GET",url,true);xmlhttp.send();}function Inputfromform(form){            { document.getElementById("tabletrack").style.display = "none";             } 			     {    var TestVar=form.inputbox.value;           }	 	 //code to eliminate space as a input	 	 if (TestVar=="")	                  {                      loadXMLDoc("Text.txt",function()                              {                        if (xmlhttp.readyState==4 && xmlhttp.status==200)                                 {                      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;                                 }	                              });                                            }		          	 else  {	//code to evaluate form.inputbox.value which should give either a "true" or "false" result var TestVar2=new RegExp(TestVar,"i");       {loadXMLDoc("XMLData.xml",function()         {   if (xmlhttp.readyState==4 && xmlhttp.status==200)            {      var xmlDoc=xmlhttp.responseXML;      var x=xmlDoc.getElementsByTagName("track");	 	       var trackValue;	  var flag=false;      for (var i=0;i<x.length;i++)                {				         trackValue = (x[i].getElementsByTagName("artist")[0].childNodes[0].nodeValue);			   		 	if (TestVar2.test(trackValue) == true)			                    {			 flag=true;	           // alert ("You Have A Match That is True: " + trackValue + flag + i );				                            {     			//Declare variables and create table, tableheader and tablebody			var oTable=document.createElement("table");			var oThead=document.createElement("thead");				var oTbody=document.createElement("tbody");			//var oRow,oCell;			//var i,j;						//Set the table's width and color			oTable.style.width = '926px';            oTable.style.backgroundColor='#c0c0c0';								              {			//Declare Table Headings			var heading = new Array();			heading[0] = "Track";			heading[1] = "Song Title";			heading[2] = "Artist";			heading[3] = "Key";			heading[4] = "Buy Now";			heading[5] = "View Cart";							            			//Insert the created elements into header			oTable.appendChild(oThead);									//Insert a row into the header and set its background color			oRow=document.createElement("tr");			oRow.style.height= '28px'			oRow.style.backgroundColor='#a8a8a8';			oRow.style.borderCollapse="collapse";			oRow.style.border = '4px solid #a8a8a8';			oThead.appendChild(oRow);			oThead.style.width = '926px';				    //Create and insert cells into the header Row								{			oCell=document.createElement("th");			oCell.innerHTML=heading[0];			oCell.style.width = '67px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[1];			oCell.style.width = '399px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[2];			oCell.style.width = '163px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[3];			oCell.style.width = '29px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[4];			oCell.style.width = '121px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[5];			oCell.style.width = '107px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}									              			               }			var x=xmlDoc.getElementsByTagName("track");			var trackValue;			     			for (var i=0;i<x.length;i++) 			              {			 trackValue = (x[i].getElementsByTagName("artist")[0].childNodes[0].nodeValue);			   		 	if (TestVar2.test(trackValue) == true)			         {  			  			//Insert the created elements into body			oTable.appendChild(oTbody);						//Insert a row into the body and set its background color			oRow1=document.createElement("tr");						oRow1.style.height= '28px';			oRow1.style.backgroundColor='#d8d8d8';			oRow1.style.borderCollapse="collapse";			oRow1.style.border = '4px solid #a8a8a8';			oTbody.appendChild(oRow1);									//Create and insert cells into the body Row						{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("number")[0].childNodes[0].nodeValue);						oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";						oData.style.fontWeight="bold";			oData.style.textAlign="center";			oData.style.width = '67px';			oData.className = 'style4';			oRow1.appendChild(oData);						}					    {			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.fontWeight="bold";			oData.style.textAlign="left";						oData.style.width = '399px';			oData.className = 'style4';			oRow1.appendChild(oData);			}		 			{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("artist")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.fontWeight="bold";			oData.style.textAlign="left";						oData.style.width = '163px';			oData.className = 'style4';			oRow1.appendChild(oData);			}						{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("key")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.fontWeight="bold";			oData.style.textAlign="center";			oData.style.width = '29px';			oData.className = 'style4';			oRow1.appendChild(oData);			}			{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("buy")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.width = '121px';			oData.className = 'style4';			oRow1.appendChild(oData);			}		    {			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("view")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.width = '107px';			oData.className = 'style4';			oRow1.appendChild(oData);			}			          }								                            }                             document.getElementById("myTable").appendChild(oTable);			                         }			                    }			                       }		 if (flag==false)//Fail Message Code      		                  {                      loadXMLDoc("Text.txt",function()                              {                        if (xmlhttp.readyState==4 && xmlhttp.status==200)                                 {				      //alert (flag);			                      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;					                                   }	                              });                                            }		  	               }         });       }    }                              		         	    }

song.js

// Java Documentfunction loadXMLDoc(url,cfunc){if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.onreadystatechange=cfunc;xmlhttp.open("GET",url,true);xmlhttp.send();}function Song(form){            { document.getElementById("tabletrack").style.display = "none";             } 			     {    var TestVar9=form.inputbox.value;           }	 	 //code to eliminate space as a input	 	 if (TestVar9=="")	                  {                      loadXMLDoc("Text.txt",function()                              {                        if (xmlhttp.readyState==4 && xmlhttp.status==200)                                 {                      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;                                 }	                              });                                            }		          	 else  {	//code to evaluate form.inputbox.value which should give either a "true" or "false" result var TestVar8=new RegExp(TestVar9,"i");       {loadXMLDoc("XMLData.xml",function()         {   if (xmlhttp.readyState==4 && xmlhttp.status==200)            {      var xmlDoc=xmlhttp.responseXML;      var x=xmlDoc.getElementsByTagName("track");	 	       var trackValue8;	  var flag=false;      for (var i=0;i<x.length;i++)                {				         trackValue8 = (x[i].getElementsByTagName("songtitle")[0].childNodes[0].nodeValue);			   		 	if (TestVar8.test(trackValue8) == true)			                    {			 flag=true;	           // alert ("You Have A Match That is True: " + trackValue + flag + i );				                            {     			//Declare variables and create table, tableheader and tablebody			var oTable=document.createElement("table");			var oThead=document.createElement("thead");				var oTbody=document.createElement("tbody");			//var oRow,oCell;			//var i,j;						//Set the table's width and color			oTable.style.width = '926px';            oTable.style.backgroundColor='#c0c0c0';								              {			//Declare Table Headings			var heading = new Array();			heading[0] = "Track";			heading[1] = "Song Title";			heading[2] = "Artist";			heading[3] = "Key";			heading[4] = "Buy Now";			heading[5] = "View Cart";							            			//Insert the created elements into header			oTable.appendChild(oThead);									//Insert a row into the header and set its background color			oRow=document.createElement("tr");			oRow.style.height= '28px'			oRow.style.backgroundColor='#a8a8a8';			oRow.style.borderCollapse="collapse";			oRow.style.border = '4px solid #a8a8a8';			oThead.appendChild(oRow);			oThead.style.width = '926px';				    //Create and insert cells into the header Row								{			oCell=document.createElement("th");			oCell.innerHTML=heading[0];			oCell.style.width = '67px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[1];			oCell.style.width = '399px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[2];			oCell.style.width = '163px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[3];			oCell.style.width = '29px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[4];			oCell.style.width = '121px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}						{			oCell=document.createElement("th");			oCell.innerHTML=heading[5];			oCell.style.width = '107px';			oCell.className = 'style2';			oCell.style.border="2px solid #0000FF";			oRow.appendChild(oCell);			}									              			               }			var x=xmlDoc.getElementsByTagName("track");			var trackValue8;			     			for (var i=0;i<x.length;i++) 			              {			 trackValue8 = (x[i].getElementsByTagName("songtitle")[0].childNodes[0].nodeValue);			   		 	if (TestVar8.test(trackValue8) == true)			         {  			  			//Insert the created elements into body			oTable.appendChild(oTbody);						//Insert a row into the body and set its background color			oRow1=document.createElement("tr");						oRow1.style.height= '28px';			oRow1.style.backgroundColor='#d8d8d8';			oRow1.style.borderCollapse="collapse";			oRow1.style.border = '4px solid #a8a8a8';			oTbody.appendChild(oRow1);									//Create and insert cells into the body Row						{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("number")[0].childNodes[0].nodeValue);						oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";						oData.style.fontWeight="bold";			oData.style.textAlign="center";			oData.style.width = '67px';			oData.className = 'style4';			oRow1.appendChild(oData);						}					    {			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.fontWeight="bold";			oData.style.textAlign="left";						oData.style.width = '399px';			oData.className = 'style4';			oRow1.appendChild(oData);			}		 			{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("artist")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.fontWeight="bold";			oData.style.textAlign="left";						oData.style.width = '163px';			oData.className = 'style4';			oRow1.appendChild(oData);			}						{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("key")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.fontWeight="bold";			oData.style.textAlign="center";			oData.style.width = '29px';			oData.className = 'style4';			oRow1.appendChild(oData);			}			{			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("buy")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.width = '121px';			oData.className = 'style4';			oRow1.appendChild(oData);			}		    {			oData=document.createElement("td");			oData.innerHTML=(x[i].getElementsByTagName("view")[0].childNodes[0].nodeValue);			oData.style.borderTop="1px groove #505050";			oData.style.borderRight="1px solid #a8a8a8";			oData.style.borderBottom="1px solid #b8b8b8";			oData.style.borderLeft="1px groove #505050";			oData.style.width = '107px';			oData.className = 'style4';			oRow1.appendChild(oData);			}			          }								                            }                             document.getElementById("myTablesong").appendChild(oTable);			                         }			                    }			                       }		 if (flag==false)//Fail Message Code      		                  {                      loadXMLDoc("Text.txt",function()                              {                        if (xmlhttp.readyState==4 && xmlhttp.status==200)                                 {				      //alert (flag);			                      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;					                                   }	                              });                                            }		  	               }         });       }    }                              		         	    }

then a sample of my xml file

<?xml version="1.0" encoding="utf-8"?>   <backing_tracks>         <track>  <number>SSBV001</number>  <title><a href="htm Tracks Files/Get%20Ready%20Backing%20Vocals.htm" class="style4" onclick="MyWindow=window.open('http://www.shellshockmusic.co.uk/htm Tracks Files/Get Ready Backing Vocals.htm','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=300,height=150'); return false;">Get Ready</a>	  </title>	  <songtitle>Get Ready</songtitle>  <artist>The Temptations</artist>  <key>C</key>  <buy><form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick"/><input type="hidden" name="hosted_button_id" value="634965"/><input class="thisinput" type="image" src="https://www.paypal.com/en_GB/i/btn/btn_cart_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online."/><img class="thisimage" alt="" src="https://www.paypal.com/en_GB/i/scr/pixel.gif"/> <!-- Softseller Code --><input name="notify_url" type="hidden" value="http://softseller.com/cgi-bin/odbic.exe/ss/odb/SSNotify.odb"/><input name="return" type="hidden" value="http://softseller.com/cgi-bin/odbic.exe/ss/odb/SSReturn.odb"/><input name="rm" type="hidden" value="2"/></form></buy><view><form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">        <input type="hidden" name="cmd" value="_s-xclick"/>        <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIG1QYJKoZIhvcNAQcEoIIGxjCCBsICAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYA6jggaiAmZFaO2UNjxfQO9rtQjI1NKGRU+of2XVzk9TBZGSRm6jwTVrfVAqszuAK0SxR2O3tK6adiPNYqY6aBguTDVnDI88xLNOZufmhulJS7fDM2biQd4Rblo5XipXEx2P/7Bvn6wlEYPTHZAa4FHLSgsMqnE7jGFq+kQkyQABDELMAkGBSsOAwIaBQAwUwYJKoZIhvcNAQcBMBQGCCqGSIb3DQMHBAiXvRRLAgw2coAwuzSnIUCB9qMEKUJ0PkvRjv5DHp/zys1hcm/QLSCfDd0B5Q/ER5u/PKr6N1vvVKgEoIIDhzCCA4MwggLsoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMB4XDTA0MDIxMzEwMTMxNVoXDTM1MDIxMzEwMTMxNVowgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBR07d/ETMS1ycjtkpkvjXZe9k+6CieLuLsPumsJ7QC1odNz3sJiCbs2wC0nLE0uLGaEtXynIgRqIddYCHx88pb5HTXv4SZeuv0Rqq4+axW9PLAAATU8w04qqjaSXgbGLP3NmohqM6bV9kZZwZLR/klDaQGo1u9uDb9lr4Yn+rBQIDAQABo4HuMIHrMB0GA1UdDgQWBBSWn3y7xm8XvVk/UtcKG+wQ1mSUazCBuwYDVR0jBIGzMIGwgBSWn3y7xm8XvVk/UtcKG+wQ1mSUa6GBlKSBkTCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMDgxMDIzMTg0NDE5WjAjBgkqhkiG9w0BCQQxFgQU9owOL8Upsz1kBSbgRI1MHubOs4cwDQYJKoZIhvcNAQEBBQAEgYBg/AdIQAKSwvHDc4EQoEI3q5fUs9HQA+WDs7rEH8rArd/tvueMuKYjx/tNUnYOVtAcj7q0WM8B11etT6O+KjjHePfGDNu5SQildXgVk45Xbvg1cTsTi6yVq1k5AKd26sHQ5GSIMqPxFXAGj5kAqM/XmPC+LPovjAxzrsceni72tw==-----END PKCS7-----"/>        <input class="thisinput" type="image" src="https://www.paypal.com/en_GB/i/btn/btn_viewcart_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online."/><img class="thisimage" alt="" src="https://www.paypal.com/en_GB/i/scr/pixel.gif"/>      </form></view>	 <view1>  </view1>  </track>etc

When running in firefox no problems it does what I expect it to do however in IE8 it is ok when I use the search by artist box but when I try to use the search by song box I get the following messageWebpage error detailsUser Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.5.30729)Timestamp: Sun, 10 Oct 2010 16:33:37 UTCMessage: Object requiredLine: 151Char: 5Code: 0URI: http://www.shellshockmusic.co.uk/song.jsLine 151 istrackValue8 = (x.getElementsByTagName("songtitle")[0].childNodes[0].nodeValue); Any ideas as to what the problem is and why it only seems to be IE that is giving the problems

Link to comment
Share on other sites

I think I have sussed out what the problem was in the songtitle tags I had on 3 tracks missed out the title and therefore had an empty tag/node now IE seems not to like this whilst Firefox chrome and other browsers dont mind and carry on regardless. Sorry about that but I supoose I live and learn

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...