Jump to content
  • 0

html and xlm


Fury

Question

hey i have a xml like this; http://apps.mta-tr.com/ASE/176.9.40.71:22078.xml

<MTA> 
<msgID>1</msgID> 
<ip>176.9.40.71</ip> 
<port>22078</port> 
<name> 
FuckN| :: Destruction Derby :: %100 DD :: The Fucking Noobs :: @FuckN.org 
</name> 
<mode>Race</mode> 
<map>Miracle Worker</map> 
<version>1.3</version> 
<num>3</num> 
<max>36</max> 
<players> 
<node>B.B|D0os</node> 
<node>[NCS]RICKARDO[24]</node> 
<node>B.B|Mad?</node> 
</players> 
</MTA> 

i want to take data's with html and show. how can i do it?

Link to comment

13 answers to this question

Recommended Posts

  • 0

<XML ID="partsList" SRC="http://apps.mta-tr.com/ASE/176.9.40.71:22078.xml"></XML> 
<table DATASRC="#partsList"> 
<thead> 
<th>Name</th><th>Mode</th><th>Map</th><th>Number</th> 
<thead> 
<tr> 
<td><SPAN DATAFLD="name"></SPAN></td> 
<td><SPAN DATAFLD="mode"></SPAN></td> 
<td><SPAN DATAFLD="mode"></SPAN></td> 
<td><SPAN DATAFLD="num"></SPAN></td> 
</tr> 
</table> 

i did this but its not working :/

Link to comment
  • 0

here:

<html> 
<body> 
  
<script> 
if (window.XMLHttpRequest) 
  {// code for IE7+, Firefox, Chrome, Opera, Safari 
  xmlhttp=new XMLHttpRequest(); 
  } 
else 
  {// code for IE6, IE5 
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
  } 
xmlhttp.open("GET","cd_catalog.xml",false); 
xmlhttp.send(); 
xmlDoc=xmlhttp.responseXML; 
  
document.write("<table border='1'>"); 
var x=xmlDoc.getElementsByTagName("CD"); 
for (i=0;i<x.length;i++) 
  { 
  document.write("<tr><td>"); 
  document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue); 
  document.write("</td><td>"); 
  document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue); 
  document.write("</td></tr>"); 
  } 
document.write("</table>"); 
</script> 
  
</body> 
</html> 

if you don't know what JavaScript is, I suggest you read more about it on the same site I posted above.

Link to comment
  • 0
Use php, example:

<? 
$xml = simplexml_load_file ( 'http://apps.mta-tr.com/ASE/176.9.40.71:22078.xml' ); 
echo $xml->name; 
?> 

Result: server name.

thanks for help. but i have a little problem.

<? 
$xml = simplexml_load_file ( 'http://apps.mta-tr.com/ASE/176.9.40.71:22078.xml' ); 
$name = $xml->name; 
$mode = $xml->mode; 
$map = $xml->map; 
$num = $xml->num; 
$max = $xml->max; 
$player = $xml->players->node; 
echo "Server Name: $name<br />Mode: $mode<br />Map: $map<br />Players: $num/$max<br />Online Players:<br />$player" 
?> 
  

i did this but it takes only first online player. how can i take all nodes at players node?

Link to comment
  • 0

you could use a foreach loop

Try this:

<?$xml = simplexml_load_file ( 'http://apps.mta-tr.com/ASE/176.9.40.71:22078.xml' );$name = $xml->name;$mode = $xml->mode;$map = $xml->map;$num = $xml->num;$max = $xml->max;$players = "";foreach($xml->players->children() as $child){     $players += $child . "
";}echo "Server Name: " . $name . "
Mode: " . $mode . "
Map: " . $map . "
Players: " . $num . "/" . $max . "
Online Players:" . $players;?> 

Read more: http://www.w3schools.com/php/php_ref_simplexml.asp

Link to comment
  • 0
you could use a foreach loop

Try this:

<?$xml = simplexml_load_file ( 'http://apps.mta-tr.com/ASE/176.9.40.71:22078.xml' );$name = $xml->name;$mode = $xml->mode;$map = $xml->map;$num = $xml->num;$max = $xml->max;$players = "";foreach($xml->players->children() as $child){     $players += $child . "
";}echo "Server Name: " . $name . "
Mode: " . $mode . "
Map: " . $map . "
Players: " . $num . "/" . $max . "
Online Players:" . $players;?> 

Read more: http://www.w3schools.com/php/php_ref_simplexml.asp

thank you dude. problem fixed:

<?$xml = simplexml_load_file ( 'http://apps.mta-tr.com/ASE/176.9.40.71:22078.xml' );$name = $xml->name;$mode = $xml->mode;$map = $xml->map;$num = $xml->num;$max = $xml->max;$players = "";echo "Server Name: " . $name . "
Mode: " . $mode . "
Map: " . $map . "
Players: " . $num . "/" . $max . "
Online Players:
";foreach($xml->players->node as $players) {    echo $players."
";}?> 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...