Fury Posted December 30, 2012 Share Posted December 30, 2012 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
0 myonlake Posted December 30, 2012 Share Posted December 30, 2012 Use Google, perhaps? http://www.w3schools.com/xml/xml_to_html.asp Link to comment
0 Fury Posted December 30, 2012 Author Share Posted December 30, 2012 Use Google, perhaps?http://www.w3schools.com/xml/xml_to_html.asp <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 Jaysds1 Posted December 30, 2012 Share Posted December 30, 2012 Actually, you would need to use JavaScript and get it, try this: http://www.w3schools.com/xml/xml_http.asp Link to comment
0 Fury Posted December 30, 2012 Author Share Posted December 30, 2012 Actually, you would need to use JavaScript and get it,try this: http://www.w3schools.com/xml/xml_http.asp can you give me a example. i really dont understand this. Link to comment
0 Jaysds1 Posted December 31, 2012 Share Posted December 31, 2012 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 Scripting Moderators Sarrum Posted December 31, 2012 Scripting Moderators Share Posted December 31, 2012 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. Link to comment
0 Jaysds1 Posted January 1, 2013 Share Posted January 1, 2013 oh, I never seen that function in php... that would've been better Link to comment
0 Fury Posted January 1, 2013 Author Share Posted January 1, 2013 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 Jaysds1 Posted January 1, 2013 Share Posted January 1, 2013 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 Fury Posted January 1, 2013 Author Share Posted January 1, 2013 you could use a foreach loopTry 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
0 Scripting Moderators Sarrum Posted January 1, 2013 Scripting Moderators Share Posted January 1, 2013 Good luck. Link to comment
Question
Fury
hey i have a xml like this; http://apps.mta-tr.com/ASE/176.9.40.71:22078.xml
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
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 accountSign in
Already have an account? Sign in here.
Sign In Now