Decrease Font Size
Increase Font Size
   BLOG

JQuery slideshow with XML

by bryian 8. October 2009 21:03

Simple Gallery with jQuery |

JQuery Simple Controls Gallery |

JQuery slideshow |

JQuery simplegallery.js |

JQuery Image Gallery with XML

Watch this Script in action/ Download

Introduction

I am using the JQuery Simple Controls Gallery from Drive DHTML (dynamic html) & JavaScript code library . One of the requirements is to read the images information from a XML file. After spending some time researching for it, I found the article Reading XML with jQuery. I have put together these two findings and include a brief explanation to it. Hope someone will find this information useful. Comments are welcome.

JQuery Slideshow

Implementation

<script type="text/javascript">
    var myArray = []; //declare and initialize array
/* 
10082009 BT
http://think2loud.com/reading-xml-with-jquery/
Read the slides info into an array from XML and assign the array variable to
the simple slide show.
*/
    $(document).ready(function() {
        $.ajax({
            type: "GET",
            url: "simplegallery_files/sites.xml", //xml file 
			dataType: "xml",
            success: function(xml) {
                var count = 0; //counter
                $(xml).find('site').each(function() {

                    var url = $(this).find('url').text(); //url 
                    var target = $(this).find('target').text(); //_blank, _new
                    var imageURL = $(this).find('imageURL').text(); //location of the image
                    var alt = $(this).find('alt').text(); //alternate text of the image

					//append to array
                    myArray[parseInt(count)] = new Array(imageURL, url, target, alt); 
					
                    count++;
                });

                var mygallery2 = new simpleGallery({
                    wrapperid: "simplegallery2", //ID of main gallery container,
                    dimensions: [728, 90], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
					
                    imagearray: myArray, //assing the array var to here
                    autoplay: [true, 10000, 99], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
                    persist: true,
                    fadeduration: 1000, //transition duration (milliseconds)
                    oninit: function() { //event that fires when gallery has initialized/ ready to run
                    },
                    onslide: function(curslide, i) { //event that fires after each slide is shown
                        //curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
                        //i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
                    }
                })
            }
        });

    });
</script>

Sample XML contents

<?xml version="1.0" encoding="iso-8859-1"?>
<sites>

  <site>
    <url><![CDATA[https://www.amazon.com/b?node=283155&tag=asp.net.books-20&camp=0&creative=0&linkCode=ur1&adid=1F4JYCPDSWG3V5JH9GD9&]]></url>
    <target>_new</target>
    <alt>Amazon :: Books</alt>
    <imageURL><![CDATA[https://images-na.ssl-images-amazon.com/images/G/01/associates/2006/books/34percent/us_books_728x90.gif]]></imageURL>
  </site>

  <site>
    <url><![CDATA[http://www.mochahost.com/1160-0-1-29.html]]></url>
    <target>_new</target>
    <alt>MochaHost</alt>
    <imageURL>http://www.mochasupport.com/aff/banners/112_728-4.gif</imageURL>
  </site>

</sites>

Comments

8/18/2009 5:32:20 PM #

trackback

JQuery slideshow with XML Data Source

You've been kicked (a good thing) - Trackback from DotNetKicks.com

DotNetKicks.com

8/19/2009 4:15:55 PM #

trackback

Daily tech links for .net and related technologies - October 9-11, 2009

Daily tech links for .net and related technologies - October 9-11, 2009 Web Development Using MvcContrib

Sanjeev Agarwal

9/4/2009 12:55:14 PM #

scratch and dent

good post Thank for sharing

scratch and dent United States

12/4/2009 8:21:23 AM #

get pregnant fast

I like this post very much I like to use on my blog.

get pregnant fast United States

12/5/2009 5:58:26 AM #

Forex Trading

Thanks for the share very usefull.

Regards
-logon2future

Forex Trading United States

12/15/2009 3:33:44 PM #

Full Tilt Rakeback

I was pretty confused about using Jquery properly but this has helped alot.  Thanks, and please continue to make new tutorials.  Btw that slideshow is pretty sweet.

Full Tilt Rakeback United States

12/22/2009 9:55:13 PM #

dstarlight

an interesting ... Smile

still learning
Ace dstarlight

dstarlight Indonesia

12/23/2009 7:21:57 AM #

backlinks

Thanks very much for the information. I have been searching for this for awhile with Google and it has been a real chore.


backlinks United States

12/24/2009 11:30:35 PM #

peninggi badan

I was very confused with JQuery ....
but after I found your article, I became was easy ....
I think you are a professional ...
thanks ..
I am waiting for your other articles ...

peninggi badan Indonesia

12/26/2009 8:22:13 PM #

Travel News

very interesting technique, thanks for share

Travel News United States

12/26/2009 8:46:22 PM #

Travel News

nice engine cms!

Travel News United States

12/27/2009 8:34:18 AM #

home loan calculator

Awesome post! Interesting info to know.

home loan calculator United States

12/29/2009 2:29:34 AM #

Free iPhone

Well that settles it.
I was going to use jQuery for another project but that just baffled the hell out of me so i'll look for another solution Wink
Oh woe is me Laughing

Thanks for the 'useful' information Wink

Free iPhone United Kingdom

1/6/2010 4:23:46 PM #

batu permata

great solution
I've long search for the article as you write this
and all were very helpful
I will continue to visit your blog

batu permata Indonesia

1/7/2010 11:11:05 PM #

Astaga.com lifestyle on the net

I think you are really an expert in writing unique blog. I am crazy about your thoughts.

Astaga.com lifestyle on the net Indonesia

1/9/2010 12:12:09 AM #

screen printing printers

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

screen printing printers United States

1/9/2010 7:02:55 PM #

rocket spanish

Learning spanish is not only going to earn you some course credits, but many people do not realize the potential buyers and sellers they can make through the use of a common language!

rocket spanish United States

1/9/2010 10:04:14 PM #

rocket spanish

Learning spanish is not only going to earn you some course credits, but many people do not realize the potential buyers and sellers they can make through the use of a common language!

rocket spanish United States

1/11/2010 2:07:53 PM #

japan

Hi,


Really appreciate this post. It’s hard to sort the good from the bad sometimes, but I think you’ve nailed it!

japan United States

1/17/2010 11:34:52 PM #

leslie

Great post.

leslie United States

1/18/2010 10:11:11 AM #

Brown Leathers

I just know I'm glad there are smart geeks out there to make life easier for the rest of us. Thanks!

Brown Leathers United States

1/19/2010 11:05:16 PM #

Jamie

Interesting post Smile

Jamie Maldives

1/25/2010 7:44:00 PM #

Dent Masters

I just saved your blog to my favorites! Just forwarded it to some of my employees. Thanks again for another great post. http://www.dentmasters.biz

Dent Masters United States

1/28/2010 12:17:48 PM #

writing essay

Thanks for providing us an easy solution. At least we don't have to waste more time researching it.

writing essay United States

2/6/2010 11:45:35 AM #

fathers day gifts

Sharing this knowledge will surely help those who are newbies and also the experts. The saying "two heads are better than one" is noticeable here.

fathers day gifts United Kingdom

2/9/2010 5:27:09 AM #

Svensk Fondservice

I never imagine that JQuery slideshow can apply with XML. Thanks for sharing the codes..I really appreciate it.

Svensk Fondservice United States

2/12/2010 4:06:03 AM #

Julio

Thanks this post help me a lot.

Julio Brazil

2/13/2010 3:21:09 PM #

non recourse debt

This blog looks really good. Thanks for providing all this information for free.

non recourse debt United States

2/14/2010 5:12:12 PM #

Mousse Coiffante

Thanks for Sharing the Infos!

Mousse Coiffante Germany

2/15/2010 3:29:28 PM #

best self tanner

What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. Feel free to visit my best self tanner review site.

best self tanner United States

2/19/2010 3:50:28 AM #

Peru Luxury Travel

I would like to thank you for your efforts you've created in crafting this report. I am hoping the same finest operate from you inside upcoming as nicely.Genuinely the blogging is spreading its wings rapidly. Your write up is often a good example of it.

Peru Luxury Travel United States

2/24/2010 2:25:42 AM #

nowGoogle.com Adalah Multiple Search Engine Popular

JQuery is great code

nowGoogle.com Adalah Multiple Search Engine Popular United States

5/25/2010 7:15:53 PM #

Sole Treadmills

Thanks for the code, it helped me out.

Sole Treadmills United States

11/18/2010 3:39:20 AM #

marriage compatibility test

I was very confused about using Jquery correctly but this information has helped a lot. Thanks again and please continue to make new tutorials. Plus the slide show shows some very interesting techniques.

marriage compatibility test United States

12/22/2010 9:26:46 PM #

Ron Spenser

I have used JQuery Simple Controls Gallery also and your summary is really helpful for those having trouble.

Ron Spenser United States

12/28/2010 4:16:07 AM #

robotic vacuum cleaner

These are the most valuable post I have collected. I have bookmarked this post. regards,

robotic vacuum cleaner United States

1/9/2011 9:42:02 PM #

Goal Setting

Thanks for the tutorial! I've been struggling with Jquery but was glad to see this breakdown done so simply. Cheers.

Goal Setting United States

Add comment


(Will show your Gravatar icon)

  Country flag

Click to change captcha
biuquote
  • Comment
  • Preview
Loading