Toon posts:

[XML/HTML] Data in nested table wordt niet weergegeven

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik ben voor mezelf bezig met het doorwerken van een boek over XML. Ik heb nu een html pagina geschreven, welke gebruikt maakt van een XML bestand.

Het rare is nu dat dit bestand de XML data in geneste tables niet weergeeft, maar als ik deze tables gewoon onder elkaar zet, wordt deze data wel weergegeven...

Ik heb met google al naar andere voorbeelden gezocht, maar overal zie ik hetzelfde. Misschien dat ik iets heel doms mis, en dat iemand anders (die er nog niet al lange tijd naar heeft zitten staren) het misschien wel gelijk ziet.

Ik zal hieronder de code geven. Het gaat om de geneste tables voor de velden "Author" en "Publisher" in het XML bestand.

De code in het Book.xml bestand:
XML:
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
<?xml version="1.0"?>
<!-- Data component of instance of the catalog object that contains book objects -->
    <Book>
        <Title >Teach Yourself XML in 24 Hours</Title>
        <Author>
            <Name >Charles Ashbacher</Name>
            <Address >119 Northwood Drive</Address>
            <City >Hiawatha</City>
            <State >Iowa</State>
            <PostalCode >52233</PostalCode>
            <Country >United States</Country>
            <Phone >(319) 378-4646</Phone>
            <Email >ashbacher@ashbacher.com</Email>
            <URL >http://www.ashbacher.com</URL>
        </Author>
        <Publisher>
            <Name >Sams Publishing</Name>
            <Address >201 West 103rd Street</Address>
            <City >Indianapolis</City>
            <State >Indiana</State>
            <PostalCode >46290</PostalCode>
            <Country >United States</Country>
            <Phone >(111) 123-4567</Phone>
            <Editor >Dummy Name</Editor>
            <EmailContact >Dummy.Name@samspublishing.com</EmailContact>
            <URL >http://www.samspublishing.com</URL>
        </Publisher>
        <ISBN >0-672-31950-0</ISBN>
        <PublisherBookID >1234567</PublisherBookID>
        <PublicationDate >2000-04-01</PublicationDate>
        <Price >24.95</Price>
    </Book>


De code in mijn html bestand:
HTML:
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<html>
<head>
    <script type="text/javascript">
        function startUp() {
            var xmlDso = xmldso.XMLDocument;
            xmlDso.load("book.xml");
        }
    </script>
</head>

<body bgcolor="white" onLoad="startUp()">
    <!--document body -->
<object width="0" height="0" classid="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" id="xmldso"></object>
    <table id="Catalog" datasrc=#xmlDso border="1" cellspacing="2">
        <tr>
            <td>
                <span style="font-size:18;font-weight:bold">Title&nbsp;</span>
                <span datafld="Title"></span>
            </td>
        </tr>
        <tr>
            <td>
                <table datasrc=#xmlDso datafld="Author" border="0" cellspacing="2">
                    <thead align=center>
                        <th>Name</th>
                        <th>Address</th>
                        <th>City</th>
                        <th>State</th>
                        <th>Postal Code</th>
                        <th>Country</th>
                        <th>Phone</th>
                        <th>Email</th>
                        <th>URL</th>
                    </thead>
                    <tr>
                        <td><span datafld="Name">&nbsp;</span></td>
                        <td><span datafld="Address">&nbsp;</span></td>
                        <td><span datafld="City">&nbsp;</span></td>
                        <td><span datafld="State">&nbsp;</span></td>
                        <td><span datafld="PostalCode">&nbsp;</span></td>
                        <td><span datafld="Country">&nbsp;</span></td>
                        <td><span datafld="Phone">&nbsp;</span></td>
                        <td><span datafld="Email">&nbsp;</span></td>
                        <td><span datafld="URL">&nbsp;</span></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <table datasrc=#xmlDso datafld="Publisher" border="0" cellspacing="2">
                    <thead align=center>
                        <th>Name</th>
                        <th>Address</th>
                        <th>City</th>
                        <th>State</th>
                        <th>Postal Code</th>
                        <th>Country</th>
                        <th>Phone</th>
                        <th>Editor</th>
                        <th>Email Contact</th>
                        <th>URL</th>
                    </thead>
                    <tr>
                        <td><span datafld="Name"> </span></td>
                        <td><span datafld="Address"> </span></td>
                        <td><span datafld="City"> </span></td>
                        <td><span datafld="State"> </span></td>
                        <td><span datafld="PostalCode"> </span></td>
                        <td><span datafld="Country"> </span></td>
                        <td><span datafld="Phone"> </span></td>
                        <td><span datafld="Editor"> </span></td>
                        <td><span datafld="EmailContact"> </span></td>
                        <td><span datafld="URL"> </span></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <span style="font-size:18;font-weight:bold">ISBN:&nbsp;</span>
                <span datafld="ISBN"></span>
            </td>
        </tr>
        <tr>
            <td>
                <span style="font-size:18;font-weight:bold">Publisher Book ID:&nbsp;</span>
                <span datafld="PublisherBookID"></span>
            </td>
        </tr>
        <tr>
            <td>
                <span style="font-size:18;font-weight:bold">Publication Date:&nbsp;</span>
                <span datafld="PublicationDate"></span>
            </td>
        </tr>
        <tr>
            <td>
                <span style="font-size:18;font-weight:bold">Price:&nbsp;</span>
                <span datafld="Price"></span>
            </td>
        </tr>
    </table>
</body>
</html>


Ik hoop dat iemand het snel ziet, en alvast bedankt 8)

Verwijderd

Topicstarter
Toch nog een oplossing gevonden. Ik laadde het xml document op deze manier in:

code:
1
2
var xmlDso = xmldso.XMLDocument;
            xmlDso.load("book.xml");


Verder maakte ik ook nog gebruik van de <object></object> tags.

Nu heb ik dit er gewoon uitgehaald, en het xml document ingeladen op de volgende manier:

code:
1
<xml id=xmldso src="book.xml"> </xml>


En zo werkt het wel. Heel vreemd, misschien iemand die ook nog weet waarom?

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 15-04 22:07

NMe

Quia Ego Sic Dico.

Je hebt waarschijnlijk meer kans in Webdesign & Graphics. ;)

PW>>WG

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Verwijderd

Topicstarter
Ow ok, ik twijfelde al een beetje aan welk forum. Maar dacht dat Webdesign en Graphics wat meer op het grafische gericht was :)