Current location: Hot Scripts Forums » General Web Coding » JavaScript » Assign URLs via a loop


Assign URLs via a loop

Reply
  #1 (permalink)  
Old 02-06-12, 09:49 AM
bigbeanbags bigbeanbags is offline
New Member
 
Join Date: Feb 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Assign URLs via a loop

Hello,
Wondering if someone could assist with some code. I have a javascript that parses an XML document. What I need to do is assign unique URLs to each <fundname> element in the XML document being parsed. Here is my code if anyone could assist? Thanks for your time!

HTML code:

<html>
<head>
<title>JQuery Easy XML Read Example</title>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){

function parse(document){
$(document).find("gipsreport").each(function(){
$("#content").append(
'<p>Acronym: '+$(this).find('acronym').text()+
'<br /> Fund Name: '+$(this).find('fundname').text()+
'</p>'
);
});
}

$.ajax({
url: 'composites.xml', // name of file you want to parse
dataType: "xml",
success: parse,
error: function(){alert("Error: Something went wrong");}
});
});
</script>

</head>
<body>
<div id="content"></div>
</body>
</html>




XML document
<?xml version="1.0" encoding="Windows-1252" standalone="no"?>
<presentvalue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<asofdate>2012-01-25</asofdate>
<data>
<gipsreport>
<acronym>AECE1</acronym>
<fundname>MFS Core Equity Composite</fundname>
</gipsreport>

<gipsreport>
<acronym>AEDEM</acronym>
<fundname>MFS Diversified Emerging Markets Equity Composite</fundname>
</gipsreport>
<gipsreport>
<acronym>AEDIV</acronym>
<fundname>MFS Diversified International Value Composite</fundname>
</gipsreport>
</data>
</presentvalue>


Thanks!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
howto get my loop in a loop working? mauricederegt PHP 12 11-27-11 03:00 PM
assembly language using notepad++, TASM, and TLINK caierhui Other Languages 0 03-18-10 10:50 AM
infinite loop versus guarded blocks UnrealEd Everything Java 0 11-11-07 02:53 PM
Dynamic image URLs in templates. aka "How to: Assign Variables ? Please Help" saymaad PHP 11 03-05-06 02:48 AM
While loop jaishalg PHP 1 11-23-04 03:36 PM


All times are GMT -5. The time now is 02:10 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.