Using jQuery with XML

Using jQuery with XML

Hey Guys. I am really new to jQuery. I am trying to use XML with jQuery and need help understanding couple of things .

In the code example below I have the following questions
  1. Why is there a var before XML but not on added on the second line before XML doc
  2. Why is there a "$" next to XML and title
  3. is the XML being passed to an jQuery obect on this line...
    $xml = $( xmlDoc ) If so what is the purpose of this ?


Any help would be really appreciated


  1.       
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>jQuery.parseXML demo</title>
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>
    <p id="someElement"></p>
    <p id="anotherElement"></p>
    <script>
    var xml = "<rss version='2.0'><channel><title>RSS Title</title></channel></rss>",
    xmlDoc = $.parseXML( xml ),
    $xml = $( xmlDoc ),
    $title = $xml.find( "title" );
    // Append "RSS Title" to #someElement
    $( "#someElement" ).append( $title.text() );
    // Change the title to "XML Title"
    $title.text( "XML Title" );
    // Append "XML Title" to #anotherElement
    $( "#anotherElement" ).append( $title.text() );
    </script>
    </body>
    </html>