Solved

Oddball xml data into a html table

Posted on 2013-12-20
3
336 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

932 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

16 Experts available now in Live!

Get 1:1 Help Now