Jump to content

Recommended Posts

Posted

<html>

<body>

<script type="text/javascript">

var xmlDoc=null;

if (window.ActiveXObject)

{// code for IE

xmlDoc=new ActiveXObject("Microsoft.XMLDOM");

}

else if (document.implementation.createDocument)

{// code for Mozilla, Firefox, Opera, etc.

xmlDoc=document.implementation.createDocument("","",null);

}

else

{

alert('Your browser cannot handle this script');

}

if (xmlDoc!=null)

{

xmlDoc.async=false;

xmlDoc.load("Alunos.xml");

document.write("<table border='1'>");

var x=xmlDoc.getElementsByTagName("Alunos");

for (i=0;i<x.length;i++)

{

document.write("<tr>");

document.write("<td>");

document.write(x.getElementsByTagName("Nome")[0].childNodes[0].nodeValue);

document.write("</td>");

document.write("<td>");

document.write(x.getElementsByTagName("Nota")[0].childNodes[0].nodeValue);

document.write("</td>");

document.write("</tr>");

}

document.write("</table>");

}

</script>

</body>

</html>

Posted

boas, não sei se isto funcionará aí, mas podes tentar fazer algo do género dentro do for

se ((i % 2) = 0) então
imprime numa cor
senão 
imprime noutra cor
fim se

espero que percebas o exemplo  ?  😉

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.