Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1113659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:53:27+00:00 2026-05-17T02:53:27+00:00

Hi I am really new to Jquery and have a problem with my script

  • 0

Hi I am really new to Jquery and have a problem with my script , I want to access the 2nd ‘heading’ tag in my xml file using jquery .
this is my script so for but what I want to do is assign a vairiable to the 2nd value of heading .

 $(document).ready(function()
        {

             $.ajax({
               type: "GET",
               url: "task.xml",
               dataType: "xml",
               success: displayXml
            });

        function  displayXml(data){

          $(data).find("tasks").each(function() {

          var heading = $(this).find("heading").text();

          });
        } 

        }); // doc ready 

this is my xml doc. What I am looking for is something like

name = $(“heading”,2).text(); the value being ‘New Job’. Can anyone help me with this please ?

        <?xml version="1.0" encoding="utf-8"?>
        <tasks>

                <heading>Home </heading>

                <heading>New Job </heading>

                <heading>System </heading>

        </tasks>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:53:27+00:00Added an answer on May 17, 2026 at 2:53 am

    Is this what are you looking for?

    $("heading:eq(1)",data).text();
    

    As you can see here in the doc http://api.jquery.com/jQuery/ jQuery() (same as $()) receives second parameter “context”, in your case this will be data and jQuery will search in this context instead of your HTML/DOM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really new to Python and I have been looking for an example
I'm really new to erlang and I'm wondering how to manipulate xml. I've found
I'm using JavScript and jQuery to read an XML document and subsequently use the
Being really new to wx, I'm wondering if there is an IDE (especially for
I'm really new to .NET, and I still didn't get the hang about how
I'm really new to ASP.Net Mvc, but not new to Asp.Net. I was aware
I'm really new to HTML, but I can't find anywhere how to return the
I recently switched over to a MacBook Pro so I'm still really new at
I haven't really looked into the new .NET stuff since 2.0, but I'm wondering
I'm new to LaTeX and I must say that I am really struggling with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.