Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML XmlReader
dear All
 
kindly i have a qustion
 
i have a code to read an xml file to make new ticker tape and i want to check element if more than zero, change the color in ticker
 
please help me if you can
 

and the code is
 
<DIV ID="TICKER" STYLE="overflow:hidden" onmouseover="TICKER_PAUSED=true" onmouseout="TICKER_PAUSED=false" class="aligncenter"/>
<script language="javascript">
var ajxObj;
if (window.XMLHttpRequest) {
ajxObj = new XMLHttpRequest();
} else {
ajxObj = new ActiveXObject('Microsoft.XMLHTTP');
}
ajxObj.open('GET', 'OutputXML.xml', false);
ajxObj.send();
 
var myXml = ajxObj.responseXML;
prs = myXml.getElementsByTagName("Table4")
for (i = 0; i < prs.length ; i++) {
document.write(prs[i].getElementsByTagName('ticker')[0].childNodes[0].nodeValue);
document.write('>>');
document.write(prs[i].getElementsByTagName('comp_current_price')[0].childNodes[0].nodeValue);
document.write(' % ');
document.write(prs[i].getElementsByTagName('change_perc')[0].childNodes[0].nodeValue);
document.write('..........');
}
</script>
</div>
Posted 20-Sep-12 2:00am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I have hardcoded the colors you can use class.
 
<DIV>
 
<script language="javascript">
var ajxObj;
if (window.XMLHttpRequest) {
ajxObj = new XMLHttpRequest();
} else {
ajxObj = new ActiveXObject('Microsoft.XMLHTTP');
}
ajxObj.open('GET', 'OutputXML.xml', false);
ajxObj.send();
 
var myXml = ajxObj.responseXML;
prs = myXml.getElementsByTagName("Table4")
 
if(prs.length >0 )
{
document.write('<DIV ID="TICKER" STYLE="overflow:hidden" onmouseover="TICKER_PAUSED=true" onmouseout="TICKER_PAUSED=false" class="aligncenter" style="background-color:#003366;" />');
}
else document.write('<DIV ID="TICKER" STYLE="overflow:hidden" onmouseover="TICKER_PAUSED=true" onmouseout="TICKER_PAUSED=false" class="aligncenter" style="background-color:#000366;" />');
 
for (i = 0; i < prs.length ; i++) {
document.write(prs[i].getElementsByTagName('ticker')[0].childNodes[0].nodeValue);
document.write('>>');
document.write(prs[i].getElementsByTagName('comp_current_price')[0].childNodes[0].nodeValue);
document.write(' % ');
document.write(prs[i].getElementsByTagName('change_perc')[0].childNodes[0].nodeValue);
document.write('..........');
}
document.write('</div>');
</script>
 
</div>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 480
1 Gihan Liyanage 225
2 OriginalGriff 174
3 Bhavik_Patel 170
4 PhilLenoir 155
0 Sergey Alexandrovich Kryukov 8,653
1 OriginalGriff 7,132
2 CPallini 2,598
3 Richard MacCutchan 2,060
4 Abhinav S 1,808


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100