/    Sign up×
Community /Pin to ProfileBookmark

Create and update table based on XML

Hi

I need to create and update a table based on an XML sent to the function. The xml can look like this:

[CODE]
<filecollection>
<file>
<filename>file1.exe</filename>
<md5>a7b8c71855547654367728fab99efa33</md5>
<status>1</status>
</file>
<file>
<filename>file2.exe</filename>
<md5>489b2760984e720b69475db97a409e8f</md5>
<status>2</status>
</file>
</filecollection>
[/CODE]

The table will show two columns, filename and status. The md5 is the md5 (!) of the filecontent and may be used as a unique id of rows. Status will be different values depending on what is being done with the file in the background.
This xml will be sent every 2-3-4 seconds, and the table need to be updated if the status has changed, or if a new file is in it, or an existing one is gone.
Do any of you know of any ready scripts out there I can use to do this. I’m not a good javascipter (obviously) and need something almost complete.

I have figured out how to create the table first time with createElement, appendChild and such. But I don’t know how to update it, and how to update the specific rows where status has changed. I could delete the table each time and rebuild it, but that would cause it to flicker, and that looks a bit bad.

Thanks for any links, suggestions or advice
Lubox

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Feb 02.2007 — You need to look at the ids of the rows and than if you find it, update the innerHTML.

Eric
Copy linkTweet thisAlerts:
@UltimaterFeb 02.2007 — myTable.rows[0] will be the first TR of the table.

myTable.rows[1].cells[0] will be the first TD of the 2nd TR.

Might want to look into:
<i>
</i>var e=myTable.rows[1].cells[0];
while(e.firstChild)e.removeChild(e.firstChild);//remove all childNodes from the TD
a.appendChild(document.createTextNode("Hello"));
a.appendChild(document.createElement("br"));
a.appendChild(document.createTextNode("World!"));

Also could do:
<i>
</i>var e=myTable.rows[1].cells[0].innerHTML="Hello&lt;br&gt;World!";
×

Success!

Help @Lubox 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.19,
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,
)...