Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with nested html tables for xml 1

Status
Not open for further replies.

oldhockey

Technical User
Oct 30, 2005
2
US
I am a novice at this and am trying to nest an xml table into my html document. I have one column working with 2 items per cell. When I try to add the 2nd (film) and 3rd (director) tables they end up in the one (year) already there. This is my code listed below… any help would be greatly appreciated! Thanks.

<html>

<head>
<title>Film List</title>
</head>

<body>
<xml id="film">
<?xml version="1.0"?>
<film>

<!-- Action Section Starts Here -->

<list>
<categories></categories>
<subcat>Martial Arts</subcat>
<filmname>
<film1>Kung Fu Hustle</film1>
<film2>The Fist</film2>
</filmname>
<director>2004</director>
<year>
<year1>1999</year1>
<year2>2000</year2>
</year>
</list>
<list>
<categories>ACTION</categories>
<subcat>War</subcat>
<director>2002</director>
<year>
<year1>1999</year1>
<year2>2000</year2>
</year>
</list>
<list>
<categories></categories>
<subcat>Science Fiction</subcat>
<director>2001</director>
<year>
<year1>1999</year1>
<year2>2000</year2>
</year>
</list>

<!-- Drama Section Starts Here -->

<list>
<categories></categories>
<subcat>Docu-drama</subcat>
<director>2004</director>
<year>
<year1>1999</year1>
<year2>2000</year2>
</year>
</list>
<list>
<categories>DRAMA</categories>
<subcat>Art</subcat>
<director>2002</director>
<year>
<year1>1999</year1>
<year2>2000</year2>
</year>
</list>
<list>
<categories></categories>
<subcat>Legal</subcat>
<director>2001</director>
<year>
<year1>1999</year1>
<year2>2000</year2>
</year>
</list>

<!-- Comedy Section Starts Here -->

<list>
<categories></categories>
<subcat>Slapstick</subcat>
<director>2004</director>
<year>
<year1>1999</year1>
<year2>2000</year2>
</year>
</list>
<list>
<categories>COMEDY</categories>
<subcat>Romantic</subcat>
<director>2002</director>
<year>
<year1>1999</year1>
<year2>2000</year2>
</year>
</list>
<list>
<categories></categories>
<subcat>Stand-Up</subcat>
<director>2001</director>
<year>
<year1>1999</year1>
<year2>2000</year2>
</year>
</list>
</film>
</xml>


<table align="center" width="100%" cellpadding="0" cellspacing="2" border="1" datasrc="#film">

<thead>
<tr>
<th>Film Categories</th>
<th>Film Sub-Categories</th>
<th>Film</th>
<th>Director</th>
<th>Year</th>
</tr>
</thead>

<tbody>

<tr>

<td><span datafld="categories"></span></td>
<td><span datafld="subcat"></span></td>
<td><span datafld="filmname"></span></td>
<td><span datafld="director"></span></td>
<td align="center">


<!-- Table design for year -->

<table width="100%" datasrc="#film" datafld="year" border="0">
<tr><td width="50%" align="left"><span datafld="year1"></span></td></tr>
<tr><td width="50%" align="left"><span datafld="year2"></span></td></tr>
</table>



<!-- Table design for film name -->

<table width="100%" datasrc="#film" datafld="filmname" border="0">
<tr><td width="50%" align="left"><span datafld="film1"></span></td></tr>
<tr><td width="50%" align="left"><span datafld="film2"></span></td></tr>
</table>


</td>

</td>

</tr>

</tbody>


</table>
</body>

</html>

new2a.htm
 
Why are you trying to embed XML into HTML? You should keep the XML file separate and use XSL to transform it to HTML:


Also, don't number elements (year1, year2, etc). They have intrinsic numbering by their position in the nodeset and it makes processing the XML harder.

Jon

"I don't regret this, but I both rue and lament it.
 
JontyMC,

Thanks for the recommendation. I separated the two, cleaned up the data and am off and running!

OldHockey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top