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

  • SEARCH
  • Home
  • 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 9023001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:39:25+00:00 2026-06-16T05:39:25+00:00

I load a XML document to jQuery using $xml = $(xmldoc) . Then I

  • 0

I load a XML document to jQuery using $xml = $(xmldoc). Then I filter it via $xml.filter('id="something"'). When using .index() on the filtered xml, jQuery returns the index in the original listing, not in the filtered listing.

Example:

<xmlroot>
  <xmlnode id="1" color="blue" />
  <xmlnode id="2" color="orange" />
  <xmlnode id="3" color="blue" />
  <xmlnode id="4" color="orange" />
  <xmlnode id="5" color="blue" />
</xmlroot>

    vObject = $xml.filter('[color="orange"]'); //vObject should just receive the xmlnodes 2 and 4
    vResult = vObject.filter('[id="4"]').index();

vResult will always be 3, but it should be 1.

I know this jQuery behaviour is by design, but I need a solution to fill vObject with the filtered xml, not with all of the xml. I’ve tried all night and I’m out of ideas.

Would be very glad if one of the experts here could help.
Thanks!

  • 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-06-16T05:39:26+00:00Added an answer on June 16, 2026 at 5:39 am

    If you want to get the index of an element within jQuery collection you should pass the element to the index method:

    var vResult = vObject.index(vObject.filter('[id="4"]')); // 1    
               // vObject.index(vObject.filter('[id="2"]')); // 0
               // vObject.index(vObject.filter('[id="3"]')); // -1
    

    http://jsfiddle.net/C9Nyg/

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

Sidebar

Related Questions

I am trying to load a 3rd party xml document using JQuery/Javascript, but without
I am trying to load a xml document I created using PHP and DOM
I want to load a xml file using Jquery . The xml is generated
I'm trying to load XML data via the jQuery get method. The XML feed
Im trying to load an xml file using the jquery ajax function,it works fine
I load an xml document from a file stream as below XmlDocument xmlDoc =
How can we load an xml document with xquery to be parsed by the
I want to load an XML document in Xerces-C++ (version 2.8, under Linux), and
I'm trying to parse and load an XML document, however I'm getting this exception
I have an XML document that I load in and try to search 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.