/    Sign up×
Community /Pin to ProfileBookmark

Getting 2+ xml tags

Hi Guys

In the following code, my XML has two contacts for TD1 – How can I output both the contact names next to eachother in the TD? I tried a nested loop but that changed the TDs for all TRs to the same name.

[CODE]var form = document.getElementById(“TabContent”);
var nLength = xOut.getElementsByTagName(‘mail’).length;

var t = document.createElement(‘table’);
t.id=”LinkTable”;
var tb = document.createElement(‘tbody’);

for(var i=0;i<nLength;i++)
{
//tr
var tr=document.createElement(‘tr’);
var trId=document.createTextNode(xOut.getElementsByTagName(“id”)[i].childNodes[0].nodeValue); //get id and insert into tr id
tr.id=trId;
tr.className=””;

//td1
var td1=document.createElement(‘td’);
td1.className=”Orders”;
var td1txt=document.createTextNode(xOut.getElementsByTagName(“fistname”)[i].childNodes[0].nodeValue + ‘ ‘
+ xOut.getElementsByTagName(“lastname”)[i].childNodes[0].nodeValue);
td1.appendChild(td1txt);

//td2
var td2=document.createElement(‘td’);
td2.className=”OrdersContent”;
var td2txt=document.createTextNode(xOut.getElementsByTagName(“title”)[i].childNodes[0].nodeValue);

var td2span = document.createElement(‘span’);
td2span.className=”OrdersContent2″;
var td2spantxt = document.createTextNode(xOut.getElementsByTagName(“content”)[i].firstChild.nodeValue);

td2.appendChild(td2txt);
td2span.appendChild(td2spantxt);
td2.appendChild(td2span);

//td3
var td3=document.createElement(“td”);
td3.className=”OrdersStatus”;
var td3txt=document.createTextNode(xOut.getElementsByTagName(“status”)[i].childNodes[0].nodeValue);
td3.appendChild(td3txt);

//td4
var td4=document.createElement(‘td’);
td4.className=”OrdersPrice”;
var td4txt=document.createTextNode(xOut.getElementsByTagName(“total”)[i].childNodes[0].nodeValue);
td4.appendChild(td4txt);

//td4
var td5=document.createElement(‘td’);
td5.className=”Date”;
var td5txt=document.createTextNode(xOut.getElementsByTagName(“date”)[i].childNodes[0].nodeValue);
td5.appendChild(td5txt);

tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.appendChild(td4);
tr.appendChild(td5);
tb.appendChild(tr);
}
t.appendChild(tb);
form.appendChild(t);

}[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorSep 09.2008 — Hi Guys

In the following code, my XML has two contacts for TD1 ...[/QUOTE]

Show us the XML
×

Success!

Help @Shaolin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...