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!