Hello, I have been working with the w3schools.com tutorials on XML and how to get it into htm. Im doing one thing differently that they dont seem to want, or like, to do though… I set up my XML to have attributes instead of just the regular way and I cant seem to figure out what I need to change in the code to make it viewable the same way as the other stuff is.
My XML file looks like this:
<game id=“20080623” home_name_abbrev=“KC” away_name_abbrev=“SF”>
<game_status status=“Final” status_ind=“F” delay_reason="" inning=“9” top_inning=“Y” b=“0” s=“0” o=“3”/>
<linescore>
<inning away=“2” home=“0”/>
<inning away=“3” home=“0”/>
<inning away=“1” home=“2”/>
<inning away=“0” home=“1”/>
<inning away=“4” home=“2”/>
<inning away=“0” home=“5”/>
<inning away=“0” home=“1”/>
<inning away=“0” home=“0”/>
<inning away=“0”/>
<r away=“10” home=“11”/>
<h away=“16” home=“14”/>
<e away=“2” home=“2”/>
</linescore>
</game>
and I was working with this from the w3school website…
<script type=“text/javascript”>
function parseXML()
{
try //Internet Explorer
{
xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);
}
catch(e)
{
try //Firefox, Mozilla, Opera, etc.
{
xmlDoc=document.implementation.createDocument("","",null);
}
catch(e)
{
alert(e.message);
return;
}
}
xmlDoc.async=false;
xmlDoc.load(“note.xml”);
document.getElementById(“to”).innerHTML=xmlDoc.getElementsByTagName(“to”)[0].childNodes[0].nodeValue;
document.getElementById(“from”).innerHTML=xmlDoc.getElementsByTagName(“from”)[0].childNodes[0].nodeValue;
document.getElementById(“message”).innerHTML=xmlDoc.getElementsByTagName(“body”)[0].childNodes[0].nodeValue;
}
</script>
Do you have any ideas on what i need to change in that code to make it so that the attribues view instead of the nodeValue?
Thanks for any help…