Solved

Oddball xml data into a html table

Posted on 2013-12-20
3
335 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
  • 2
3 Comments
 
LVL 35

Expert Comment

by:Robert Schutt
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now