Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    build Table using javascript from xml.file

    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
    Code:
    <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>
    can upload the file
    Code:
    <xml
    src=" Sample.xml"
    id="xmldso"
    async="false">
    </xml>
    I would like to create a table with 2 columns for AssayNumber and the second for SourcePlate
    Code:
    <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>
    But I don't know how to populate
    I have tried with
    Code:
    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);
    			};

    Many thanks for your advice and ideas

  • #2
    New Coder
    Join Date
    Nov 2006
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Canaille,

    This link will help.

    http://www.sitepoint.com/article/ser...xml-javascript
    Chandan
    Share knowledge, it only expands

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank Chandan

    I am going to study this article


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •