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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:24:35+00:00 2026-06-12T21:24:35+00:00

I’m building up a function in jQuery that populate an array from an XML.

  • 0

I’m building up a function in jQuery that populate an array from an XML.
The XML comes out of another application, so I cannot change it.

The function is meant to preload image after the array is created.
Everything works well except that I am not able to distinguish child tags with same name under different parent tags.

Well, here is the jQuery code:

 (function() {
{
setTimeout(function(){

var splashArray = new Array();
// Load the Splash XML file and assign each image within to an array
$.get('images.xml', function(xml) {

The problem is here:

 $('album', xml).each(function (i) {
        var path = $(this).attr("lgpath");
        $('img', xml).each(function (i) {
         splashArray.push("/fotografie-matrimonio/" + path + $(this).attr("src"));

see below for the problem!

    });
    });
    work_with_splash();
});
function work_with_splash () {
    Object.size = function(obj) {
    var size = 0, key;
    for (key in obj) {
    if (obj.hasOwnProperty(key)) size++;
      }
     return size;
    };
    // Get the size of an object
    var size = Object.size(splashArray);
    var i = 0;
    for(i=0; i<size; i++) new Image().src = splashArray[i];
                /*alert(result[X]);*/   
} //closes the spalsh Call

}, 1000);
};

and here the XML structure:

<album id="1" lgpath="thePath 1/" ...>
    <img src="name of photo 1" ....></img>
    <img src="name of photo 2"....></img>
    <img src="name of photo 3"....></img>
</album>
<album id="2" lgpath="thePath 2/" ...>
    <img src="name of photo 1" ....></img>
    <img src="name of photo 2"....></img>
    <img src="name of photo 3"....></img>
</album>

The script works, but what it does is the it load for each album path all the img src (also the ones of the others album path.

What I want to do is: to process the img tags in groups by the parent tags.
I don’t know if I am clear!

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-12T21:24:36+00:00Added an answer on June 12, 2026 at 9:24 pm

    I’ve solved!

    Easy…

    just change the code from:

     $('album', xml).each(function (i) {
        var path = $(this).attr("lgpath");
        $('img', xml).each(function (i) {
         splashArray.push("/fotografie-matrimonio/" + path + $(this).attr("src"));
    

    to:

     $('img', xml).each(function (i) {
            var path = $(this).parent().attr("lgpath");
            splashArray.push("/fotografie-matrimonio/" + path + $(this).attr("src"));
        });
    

    using the .parent() method.

    Hope it will help somebody!

    Cheers 🙂

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

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.