SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot XandroZ's Avatar
    Join Date
    May 2006
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse a XML element with AJAX

    I need to parse a element from a XML file:

    <a>
    <b>45</b>
    <c>67</c>
    </a>

    <a>
    <b>98</b>
    <c>89</c>
    </a>

    So I try to read and put in a html element the first value of b with the next code:


    Code:
    document.getElementById("apDiv3").innerHTML=xmlDoc.getElementsByTagName("b")[0].data;
    
    or
    
    document.getElementById("apDiv3").innerHTML=xmlDoc.getElementsByTagName("b")[0].value;
    and I get a undefined message.Where is the problem?

  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try getElementsByTagName('b')[0].childNodes[0].value instead.


Bookmarks

Posting Permissions

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