|
I have written a function to display my xml document. I am passing my xml document in variable xmldoc. The function I have written works great but only outputs my first entry in the XML document. How can I make this loop through my XML and output everything? Also I only have a single <a> tag with the id of "link" how do I get the results to show up?! thanks for taking a look!
javascript:
function showData(xmldoc){
var docElement, usernameNode, usernameidNode, displayText, linkValue;
docElement = xmldoc.documentElement;
usernameNode = docElement.firstChild;
usernameidNode = usernameNode.nextSibling;
displayText = usernameNode.firstChild.nodeValue;
linkValue = "http://www.mediamishmash.com/profiles.php?user=" + usernameidNode.firstChild.nodeValue;
var target = document.getElementById('link');
target.innerHTML = displayText;
target.href = linkValue;
}
XML Structure:
<?xml version="1.0" ?>
<usernamedata>
<username>Tim</username>
<usernameid>1</usernameid>
<username>Sam</username>
<usernameid>2</usernameid>
<username>Fred</username>
<usernameid>3</usernameid>
</usernamedata>
|