• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

Oddball xml data into a html table

I got a project pushed on me and I thought I could bang it out then move on my hockey project. I'm just using some successful code for boxing and at the top is the champion then it goes 1 to 10 for rankings and this happens for like 8 different weight classes I made the table 750 and then I made one table 375 and I wanted to clone that table and can it do two 375 tables a row but The xml is just champion ,rank , name the tags are the same in same node making me clueless how to code this. Please Help That's what you get for more work.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>International Boxing Federation Official Rankings</title>
<link rel="stylesheet" href="http://powerzsoftware.com/css/jquery-ui-1.8.9.customver1.css">
<style type="text/css">
	#players { width: 410px; height: 400px; overflow: hidden; }
	#players ul li { list-style-type: none; border-bottom:1px solid green; }
	.playerTable td { vertical-align:top; }
	
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {

$.ajax({url: 'BPX-IBFRANK.xml'})
	.done(function(data) {
		$('Listing', data).each(function(i, tablerank) {
			var playerInfo = $(tablerank);
			var newFighter = $('#template').clone().removeAttr('id');
				$('.champion', newFighter).text( playerInfo.attr('Champion') );
			$('.name', newFighter).text( $('Name', playerInfo).text() );
				
			$('.name', newFighter).text( $('Name', playerInfo).text() );
			$('.name', newFighter).text( $('Name', playerInfo).text() );
			$('.name', newFighter).text( $('Name', playerInfo).text() );
				
			$('.name', newFighter).text( $('Name', playerInfo).text() );
			$('.name', newFighter).text( $('Name', playerInfo).text() );
			$('.name', newFighter).text( $('Name', playerInfo).text() );
				
			$('.name', newFighter).text( $('Name', playerInfo).text() );
			$('.name', newFighter).text( $('Name', playerInfo).text() );
			$('.name', newFighter).text( $('Name', playerInfo).text() );
			
			$('#players ul').append( $('<li>').append(newFighter) );
		
				
	
				
				});
	});
});
</script>
</head>

<body>
<div id="players" >
	<ul></ul>
</div>
<table width="750" border="0">
  <tr>
    <td><div align="center" class="GCPBP">International Boxing Federation Official Rankings</div></td>
  </tr>
</table>
<table width="375" border="0" id="template" class="playerTable">
  <tr>
    <td><div align="center">Weight_Class</div></td>
    <td><div align="center">Heavyweight  (over 190 pounds)</div></td>
  </tr>
  <tr>
    <td><div align="center">Champion</div></td>
    <td class="champion"><div align="center" ></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 1</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 2</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 3</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 4</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 5</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 6</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 7</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 8</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 9</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 10</div></td>
    <td class="Name><div align="center"></div></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>

Open in new window

boxing.html
BPX-IBFRANK.xml
0
powerztom
Asked:
powerztom
  • 2
1 Solution
 
Robert SchuttSoftware EngineerCommented:
Make sure your html is valid:
<table width="375" border="0" id="template" class="playerTable">
  <tr>
    <td><div align="center">Weight_Class</div></td>
    <td><div align="center">Heavyweight  (over 190 pounds)</div></td>
  </tr>
  <tr>
    <td><div align="center">Champion</div></td>
    <td class="champion"><div align="center" ></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 1</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 2</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 3</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 4</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 5</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 6</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 7</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 8</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 9</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 10</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
</table>

Open in new window

Then something like this seems close, but have a look and tell me what may be missing.
<script type="text/javascript">
$(document).ready(function() {

$.ajax({url: 'BPX-IBFRANK.xml'})
	.done(function(data) {
		$('Listing', data).each(function(i, tablerank) {
			var playerInfo = $(tablerank);
			var newFighter = $('#template').clone().removeAttr('id');
			$('.champion', newFighter).text( playerInfo.attr('Champion') );
			$('.name', newFighter).each(function(iRow, oRow){
				$(oRow).text( $( $('Name', playerInfo)[iRow] ).text() );
			});
			$('#players ul').append( $('<li>').append(newFighter) );
		});
	});
});
</script>

Open in new window

0
 
Robert SchuttSoftware EngineerCommented:
made some more changes (2 on a row I just noticed...)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>International Boxing Federation Official Rankings</title>
<link rel="stylesheet" href="http://powerzsoftware.com/css/jquery-ui-1.8.9.customver1.css">
<style type="text/css">
	#players { width: 950px; height: 400px; overflow: scroll; }
	#players ul li { list-style-type: none; border-bottom:1px solid green; float: left; display: block; }
	.playerTable td { vertical-align:top; display:none;}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {

$.ajax({url: 'BPX-IBFRANK.xml'})
	.done(function(data) {
		$('Listing', data).each(function(i, tablerank) {
			var playerInfo = $(tablerank);
			var newFighter = $('#template').clone().removeAttr('id').removeClass('playerTable');
			$('.Weight_Class', newFighter).text( $('Weight_Class', playerInfo).text() );
			$('.champion', newFighter).text( $('Champion', playerInfo).text() );
			$('.name', newFighter).each(function(iRow, oRow){
				$(oRow).text( $( $('Name', playerInfo)[iRow] ).text() );
			});
			$('#players ul').append( $('<li>').append(newFighter) );
		});
	});
});
</script>
</head>

<body>
<table width="750" border="0">
  <tr>
    <td><div align="center" class="GCPBP">International Boxing Federation Official Rankings</div></td>
  </tr>
</table>
<div id="players" >
	<ul></ul>
</div>
<table width="375" border="0" id="template" class="playerTable">
  <tr>
    <td><div align="center">Weight_Class</div></td>
    <td><div align="center" class="Weight_Class">Heavyweight  (over 190 pounds)</div></td>
  </tr>
  <tr>
    <td><div align="center">Champion</div></td>
    <td class="champion"><div align="center" ></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 1</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 2</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 3</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 4</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 5</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 6</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 7</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 8</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 9</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
  <tr>
    <td><div align="center">Rank 10</div></td>
    <td class="name"><div align="center"></div></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>

Open in new window

0
 
powerztomAuthor Commented:
Rob came out of retirement today and showed why he in the EE Hall of Fame. Couldn't ask for a better solution.Thank You Rob AND EE
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now