XML - Binding HTML Tables to XML Data

 
Vista:

Binding HTML Tables to XML Data

Publicado por Gemma (1 intervención) el 19/05/2014 10:53:52
Hi!

I'm trying to display hml data in an html table. I've found this example on the internet:

Html code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<HTML>
    <HEAD>
        <TITLE>
            Displaying XML data using XML data islands
        </TITLE>
    </HEAD>
 
    <BODY>
        <H1>
            Displaying XML data using XML data islands
        </H1>
 
        <XML SRC="ch19_03.xml" ID="states"></XML>
 
        <TABLE DATASRC="#states" BORDER="1">
             <THEAD>
                 <TR>
                     <TH>Name</TH>
                     <TH>Population</TH>
                     <TH>Capital</TH>
                     <TH>Bird</TH>
                     <TH>Flower</TH>
                 </TR>
              </THEAD>
 
              <TBODY>
                  <TR>
                      <TD>
                          <SPAN DATAFLD="name">
                          </SPAN>
                      </TD>
                      <TD>
                          <SPAN DATAFLD="population">
                          </SPAN>
                      </TD>
                      <TD>
                          <SPAN DATAFLD="capital">
                          </SPAN>
                      </TD>
                      <TD>
                          <SPAN DATAFLD="bird">
                          </SPAN>
                      </TD>
                      <TD>
                          <SPAN DATAFLD="flower">
                          </SPAN>
                      </TD>
                  </TR>
              </TBODY>
        </TABLE>
    </BODY>
</HTML>

XML file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?xml version="1.0" encoding ="UTF-8"?>
<states>
 
    <state>
        <name>California</name>
        <population>33871648</population>
        <capital>Sacramento</capital>
        <bird>Quail</bird>
        <flower>Golden Poppy</flower>
        <area units="square miles">155959</area>
    </state>
 
    <state>
        <name>Massachusetts</name>
        <population>6349097</population>
        <capital>Boston</capital>
        <bird>Chickadee</bird>
        <flower>Mayflower</flower>
        <area units="square miles">7840</area>
    </state>
 
    <state>
        <name>New York</name>
        <population>18976457</population>
        <capital>Albany</capital>
        <bird>Bluebird</bird>
        <flower>Rose</flower>
        <area units="square miles">47214</area>
    </state>
 
</states>


But when I try to do it, it doesn't work :( It creats the table with the titles but it's not importing the data. Can anyone help me?

thank you!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder