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 5957821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:27:21+00:00 2026-05-22T18:27:21+00:00

my xml: <stuffs> <unit id=code>10</unit> </stuffs> my jquery ajax: $.ajax({ type: POST, url: xml/test.xml,

  • 0

my xml:

<stuffs>
<unit id="code">10</unit>
</stuffs>

my jquery ajax:

 $.ajax({
             type: "POST",
             url: "xml/test.xml",
             dataType: "xml",
             success: function(xml) {
                   $(xml).find('stuffs').each(function(){

                        ... the code are here ...

                });
             }

i’m trying to get the values from <unit> using the ID:

var unit = $(this).find('unit').attr('id');
var unitIdVal = $("#"+unit).text();
alert(unitIdVal);

but, nothing he found.

i dont know if is the same method of a comun jquery stuff’s
because i try to get the value direct using

var unitIdVal = $("#code").text();

but, nothing again.

ty

  • 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-22T18:27:22+00:00Added an answer on May 22, 2026 at 6:27 pm

    Your selector stuff above is wonky to say the least. You’re getting the ID off of an element and then getting that element once again by ID, all within a loop that does nothing for you…

    Here’s what it needs to be:

    var unit = $(this).find('unit').attr('id');
    var unitIdVal = $("#"+unit, xml).text(); //provide context to your selector
    

    I feel dirty even writing this though, and I hope that it’ll be used in a different context and this is merely illustrative.

    Here’s what it should be. Note the lack of selecting the very same element that you got the ID off of:

    //....
    success: function(xml) {
        var unitIdVal = $(xml).find('unit').text();
    }
    //....
    

    Please read some helpful tutorials on XML parsing thoroughly.

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

Sidebar

Related Questions

The XML Schema Part 2 specifies that an instance of a datatype that is
Which XML validation tools can you recommend for both performance and accuracy, each of
I am looking to implement a continuous unit test running system, something I have
I have a rest/xml service that gives me the following... <verse-unit unit-id=38009001> <marker class=begin-verse
Hi I'm new to the whole xml type stuff. I've built a ROM called
I am parsing some XML something like this: <root> <some_gunk/> <dupe_node> ... stuff I
I have a huge bunch of XML files with the following structure: <Stuff1> <Content>someContent</name>
This XML file contained archived news stories for all of last year. I was
The XML I'm trying to validate is as follows: <root> <element attribute=foo> <bar/> </element>
An XML attribute declared as xs:boolean can acceptable be true, false, 0 or 1.

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.