XML Parsing for Image URLs — Help
Hello, I am a new comer to jQuery transferring from flash.
Im trying to parse an XML file that has holds the URLs to about 10 images.
However, all the tutorials I have followed do not seem to work.
Ive been trying this for a few days now and I was hoping one of your jQuery gurus may see something I dont.
Here are my codes :
XML :
- <?xml version="1.0" encoding="UTF-8"?>
- <Images>
- <image url="_work/_new/balloonsfocusxtraballoons.jpg"></image>
-
- <image url="_work/_new/bkyrd.jpg"></image>
-
- <image url="_work/_new/bush.jpg"></image>
-
- <image url="_work/_new/chair.jpg"></image>
-
- <image url="_work/_new/church.jpg"></image>
-
- <image url="_work/_new/dancer2.jpg"></image>
-
- <image url="_work/_new/dannyhilljr2combo.jpg"></image>
-
- <image url="_work/_new/EPmarket.jpg"></image>
-
- <image url="_work/_new/eyecontact.jpg"></image>
-
- <image url="_work/_new/fooetkingblanket2.jpg"></image>
-
- <image url="_work/_new/gary_working.jpg"></image>
-
- <image url="_work/_new/garyinbed_lipseyes.jpg"></image>
-
- <image url="_work/_new/gorgeunderpass.jpg"></image>
-
- <image url="_work/_new/griffithlamp.jpg"></image>
-
- <image url="_work/_new/infinty.jpg"></image>
-
- <image url="_work/_new/mcs.jpg"></image>
-
- <image url="_work/_new/oceanafterserra.jpg"></image>
-
- <image url="_work/_new/oldenglish.jpg"></image>
-
- <image url="_work/_new/selfportraitofmeasmygrandfather.jpg"></image>
-
- <image url="_work/_new/signs.jpg"></image>
-
- <image url="_work/_new/streetlightfocusared.jpg"></image>
- </Images>
HTML (with jQuery at the top):
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>xml parse test</title>
- <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- $.get('newimages.xml', function(d){
- $('div#content').append('<h1>Images</h1>');
-
- $(d).find('image').each(function(){
- var $image = $(this);
- var imageUrl = $image.attr("url").text();
-
- var html = '<img src="' + imageUrl + '" />';
-
- $('div#content').append($(html));
- });
- });
- });
- </script>
- </head>
- <body>
- <div id="content" style="background-color:#999; position:absolute; top:150px; left: 200px; width: 1000px; max-width:width: 1000px; height:inherit; min-height:500px;">
- </div>
- </body>
- </html>
Thanks in advance for your help.