Solved

Oddball xml data into a html table

Posted on 2013-12-20
3
339 Views
Last Modified: 2013-12-20
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
Comment
Question by:powerztom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39732540
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
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39732570
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
 

Author Closing Comment

by:powerztom
ID: 39732629
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question