SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist JordashTalon's Avatar
    Join Date
    Dec 2008
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parsing an XML Like String in Javascript / Jquery

    I'm trying to learn the basics of XML parsing, I know how to get data from a SQL database but I can't get the JQuery XML Parsing to work properly.

    This is the basic thing i'm trying:

    Code:
    var xml = '<url>urlofpage1</url><notes>These notes should load!</notes>';
    var $xml = $(xml);
    
    var $notes = $xml.find('url')
                     .filter(function() { return $(this).text() == 'urlofpage1' })
                     .closest('notes');
    
    console.log('$notes: ', $notes);
    It either returns null or [object Object]

    I'm trying to select the note closest to the <url> tag which contains urlofpage1

    What am I Doing wrong?

    Thanks for any help

  2. #2
    SitePoint Evangelist JordashTalon's Avatar
    Join Date
    Dec 2008
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any ideas?


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
  •