Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
How do you output an XML document with multiple entries?
Old 05-22-2006, 04:56 PM How do you output an XML document with multiple entries?
Novice Talker

Posts: 9
Trades: 0
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>
twizler is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to How do you output an XML document with multiple entries?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08471 seconds with 12 queries