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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:13:28+00:00 2026-06-08T15:13:28+00:00

I am using a normal variable to display the list of images. But the

  • 0

I am using a normal variable to display the list of images. But the same thing I need is by using the XML. Can anyone please help me. The var ‘imgs’ should be an xml.

Jquery

$(function() {

    var imgs = ['http://www.academy-florists.com/images/shop/thumbnails%5CValentines_Day_flowers.jpg', 'http://www.everythingbuttheprincess.com/assets/images/babies-in-bloom-fuchsia-flower_thumbnail.jpg', 'http://www.behok.ru/i/a/cat/gerbera.jpg', 'http://www.thebutterflygrove.com/images/thumbnails/0/200/200/thumbnail_flower-decor-makpk.jpg', 'http://gameinfestedent.com/gallery_photo/medium_image/image1322820610_MainPurpleOrchids3_1a.jpg'];

   var maximages = imgs.length; //No of Images
   Slider();
   setInterval(Slider, 3000);
   var prevIndex = 0, prevPrevIndex = 0;

   function Slider() {
       $('#imageSlide').fadeOut("slow", function() {
           do {
               shuffleIndex = Math.floor(Math.random() * maximages);
           } while(prevIndex == shuffleIndex || prevPrevIndex == shuffleIndex)

           prevPrevIndex = prevIndex;
           prevIndex = shuffleIndex;

           $("#panel").fadeIn("slow").css('background', '#000');

           $(this).attr('src', imgs[shuffleIndex]).fadeIn("slow");
       });
   }

});
  • 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-08T15:13:30+00:00Added an answer on June 8, 2026 at 3:13 pm

    You haven’t told us what your xml would look like so I’ve together the following basic schema

    <?xml version="1.0" encoding="utf-8" ?>
    <images>
        <image>url of image</image>
        <image>url of next image</image>
    <images>
    

    If you search the jQuery site you will find that it tells you how to work with Xml – http://api.jquery.com/jQuery.parseXML/

    You need to use parseXML on your xml string and convert to a jQuery object. You can then find() elements, loop through elements or pickout the elements text and attributes. The following example shows this.

    $(function() {
    
        // your image list as xml string
        var xmlStr = '<?xml version="1.0" encoding="utf-8" ?><images><image>http://www.academy-florists.com/images/shop/thumbnails%5CValentines_Day_flowers.jpg</image><image>http://www.everythingbuttheprincess.com/assets/images/babies-in-bloom-fuchsia-flower_thumbnail.jpg</image><image>http://www.behok.ru/i/a/cat/gerbera.jpg</image><image>http://www.thebutterflygrove.com/images/thumbnails/0/200/200/thumbnail_flower-decor-makpk.jpg</image><image>http://gameinfestedent.com/gallery_photo/medium_image/image1322820610_MainPurpleOrchids3_1a.jpg</image></images>';
    
        // parse the xml and produce an jQuery image object ($image) to represent the list of image elements
        var xmlDoc = $.parseXML(xmlStr),
            $xml = $(xmlDoc),
            $image = $xml.find("image");
    
        // loop throught your image elements and alert the url
        $image.each(function() {
            var imageElement = this, // this within the loop is the current element
                $imageElement = $(imageElement),
                imageUrl = $imageElement.text(); // use text to get the url
    
            alert(imageUrl);
        });
    
        // use length on the jQuery object to get the element count
        var maximages = $image.length;
        alert(maximages);
    
        var shuffleIndex = 3,
            imageElement = $image[shuffleIndex], // index the random image that you want to use
            $imageElement = $(imageElement),
            imageUrl = $imageElement.text();
    
        alert(imageUrl);
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to do: I am using the normal auto-fill function in Excel (double
Right, perhaps I should be using the normal Python lists for this, but here
My code looks close to this: Lots of writes using normal C++ IO stream
If I have a jQuery plugin using the normal standard of: (function( $ ){
Logged into my Windows XP SP2 computer using my normal user account (which has
I'm using ExpressJS with normal HTML templates (no Jade or similar template engines). Since
A friend of mine has to send a normal email using ONLY HTML/HTML5 (or
I have a function that generates normal random number matrix having normal distribution using
I'm writing a small function to generate values from the Normal distribution using Box-Muller
Using an Oracle temporary table does not generate much redo log as a normal

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.