The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 1 of 1

Thread: Viewing XML Attributes in Browsers

  1. #1

    Viewing XML Attributes in Browsers

    Hello, I have been working with the 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"/>
    <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"/>

    and I was working with this from the w3school website....

    <script type="text/javascript">
    function parseXML()
    try //Internet Explorer
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    try //Firefox, Mozilla, Opera, etc.
    xmlDoc=document.implementation.createDocument(""," ",null);
    document.getElementById("to").innerHTML=xmlDoc.get ElementsByTagName("to")[0].childNodes[0].nodeValue;
    document.getElementById("from").innerHTML=xmlDoc.g etElementsByTagName("from")[0].childNodes[0].nodeValue;
    document.getElementById("message").innerHTML=xmlDo c.getElementsByTagName("body")[0].childNodes[0].nodeValue;

    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...
    Last edited by JCampos021; June 23rd, 2008 at 05:02 PM. Reason: more explanation of what im trying to do

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012