473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

build Table using javascript from xml.file

8
Hi,
I am newby in Xml
I want to build a table that i can later manipulate in javascript
The Sample.xml contains several Assay with varying number of sample; it looks like that
[HTML]
<Assay AssayType="DNA" AssayNumber="3">
<Sample>
<Destination Position="D2"/>
<Source SourcePlate="P3" SourcePos="A2" sourceConc=2"/>
</Source>
</Sample>
<Sample>
<Destination Position="D12"/>
<Source SourcePlate="P5" SourcePos="C1" sourceConc=3"/>
</Source>
</Sample>
<Sample>
<Destination Position="D5"/>
<Source SourcePlate="P7" SourcePos="B1" sourceConc=1"/>
</Source>
</Sample>
</Assay>
<Assay AssayType="DNA" AssayNumber="5">
<Sample>
<Destination Position="A3"/>
<Source SourcePlate="P4" SourcePos="A9" sourceConc=4"/>
</Source>
</Sample>
<Sample>
<Destination Position="D2"/>
<Source SourcePlate="P5" SourcePos="R1" sourceConc=2"/>
</Source>
</Sample>

</Assay>[/HTML]
I can upload the file
[HTML]<xml
src=" Sample.xml"
id="xmldso"
async="false">
</xml>[/HTML]
I would like to create a table with 2 columns:one for AssayNumber and the second for SourcePlate
[HTML]<table
datasrc="#xmldso"
width="100%"
border="1">
<thead>
<th>AssayNumber</th>
<th>SourcePlate</th>
</thead>
<tr>
<td><span datafld="AssayNum"></span></td>
<td><span datafld="SourceP"></span></td>
</tr>
</table>[/HTML]
But I don't know how to populate
I have tried with
[HTML]function populateTable(){
for (i=0;i<Sample.xml;i++){
var TheDatas=xmldoc.getElementsByTagName('Assay');
var AssayNum=TheDatas[i].getElementsByTagName('AssayNumber')[i].getAttribute('AssayNumber');
alert('AssayNumber='+AssayNum);
var desc=TheDatas[i].getElementsByTagName('AssayNum')[i];


SourceP=desc.getElementsByTagName('Source')[i].getAttribute('SourcePlate');
alert( 'SourcePlate '+ SourceP);
};[/HTML]
Many thanks for your advice and ideas
Jan 31 '07 #1
2 2288
acoder
16,027 Expert Mod 8TB
Read an XML DOM tutorial. The examples will be helpful too.

If you have any problems, post again.
Jan 31 '07 #2
Bogey
8
Thank Acoder
I will study the tutorial and the examples
Jan 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
5
by: john_williams_800 | last post by:
Hi; I am just starting to use the DOM to do some more advanced javascripting so please be patient with my question if it is an ignorant question. I would like to use the DOM to dynamically...
3
by: vanisathish | last post by:
Hi I am running a client side javascript timer to periodically refresh the contents of some tables in the HTML page. The table values are dynmically binded from XML DOM object using the <XML tag...
4
by: Unknown | last post by:
When I create a Table webcontrol programmatically (no static table tag in the aspx file), it renders in the HTML with a border attribute set to "0". If I add my own border...
6
by: iKiLL | last post by:
Hi all I am developing in C#, CF2 and SQL Mobile. Currently my app is using Merge Replication. This is all working well. I have now decided to try and use Result sets in my application but I...
7
by: Mariusf | last post by:
I am a novice Perl programmer and need to change a perl script that I use to create web pages with thumbnail images and some text. Currently the script created a web page for each artist / category...
15
by: fanchun | last post by:
I already built 2 javacript files factor.js and parm.js. factor.js is an array, having several factor as elements. for example, factor.js looks like: var factor= parm.js is also an array, having...
7
by: ms026057 | last post by:
I Have a File a.html file Content <html> <body> <table> <tr><td id="table1">this content from b.html</td></tr> </table> </body> <html>
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.