# Viewing XML Attributes in Browsers

**URL:** <https://forum.kirupa.com/t/viewing-xml-attributes-in-browsers/264168>\
**Category:** programming\
**Created:** [June 23, 2008, 6:34pm UTC](https://forum.kirupa.com/t/viewing-xml-attributes-in-browsers/264168 "2008-06-23T18:34:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JCampos021](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@JCampos021](https://forum.kirupa.com/u/JCampos021)\
**Post date:** [June 23, 2008, 6:34pm UTC](https://forum.kirupa.com/t/viewing-xml-attributes-in-browsers/264168/1 "2008-06-23T18:34:45Z")

</div>

Hello, I have been working with the [w3schools.com](http://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…
