/    Sign up×
Community /Pin to ProfileBookmark

XML Text Nodes

I have an AJAX application using which im attempting to acces a #Text node in the NAME tag of an XML document. i then want to sort the names and place them into tables <td> tag. i can put the names in the <td> but i want them sorted alphabeticaly.

from my understanding im suppose to be able to sort an array simply like this Array[].sort();…………..this is the reason i need the text to be an array. Unless you know a simpler way to do this.

[CODE]

function postNames(){
var signersdoc = xmlHttp.responseXML;
var container = document.getElementsByTagName(“td”);
var data = signersdoc.getElementsByTagName(“Names”);
for ( var j = 0; j < container.length && j < data.length; j++) {
var key = container[j].firstChild.nodeValue;
var name = data[j].firstChild.nodeValue;
key = name;
}
}

<DOC>
<NAME>uknowmeim</NAME>
<NAME>bob</NAME>
<NAME>jANE</NAME>
</DOC>
[/CODE]

<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@AlphaBravoXOct 22.2010 — What´s the problem? Get all the names from the XMLDocument, put them in an array, use sort() on that array and finally write the names in the TD-Tags!
Copy linkTweet thisAlerts:
@uknowmeimauthorOct 22.2010 — For some reason is is not working for me.

[CODE]

function postNames(){
var signersdoc = xmlHttp.responseXML;
var container = document.getElementsByTagName("td");
var data = signersdoc.getElementsByTagName("Names");
for ( var j = 0; j < container.length && j < data.length; j++) {
var key = container[j].firstChild.nodeValue;
var name = data[j].firstChild.nodeValue.sort();
key = name;
}
}


[/CODE]
×

Success!

Help @uknowmeim 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.25,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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