Shoutbox

Include XML ? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Include XML ? (/showthread.php?tid=73641)

Include XML ? by Eddie on 04-16-2007 at 09:45 AM

Is there a way i can include this into my website "http://www.habbo.com.au/habbo_count_xml.action" *-) I've googled but can't figure it out. :(

P.S. I want to include that url (xml in it) into my website *-)


RE: Include XML ? by Nathan on 04-16-2007 at 10:06 AM

<?php
include('http://www.habbo.com.au/habbo_count_xml.action');
?>

I doubt it will work beccause it's on a different server but give ti a try


RE: Include XML ? by Eddie on 04-16-2007 at 10:10 AM

quote:
Originally posted by Nathan
<?php
include('http://www.habbo.com.au/habbo_count_xml.action');
?>

I doubt it will work beccause it's on a different server but give ti a try
i figured it out :) but thanks anyway (Y)
RE: Include XML ? by absorbation on 04-16-2007 at 12:40 PM

Do you want to include the XML file, or split it up into various variables to use in your own way? Because you will need to do it differently to your current method. If that is the case I'll gladly explain how to do it in detail :).


RE: Include XML ? by Eddie on 04-16-2007 at 01:05 PM

quote:
Originally posted by absorbation
Do you want to include the XML file, or split it up into various variables to use in your own way? Because you will need to do it differently to your current method. If that is the case I'll gladly explain how to do it in detail :).
if you look at that file, all i want to be shown is the number, and i have to link to that file for the number to come up, but if you think there is a good way then please let me know :)
RE: Include XML ? by absorbation on 04-16-2007 at 01:17 PM

Then your way is fine just to show a number. If you want to take the number and use it for something else, you would need to use a different method :P.


RE: Include XML ? by Eddie on 04-17-2007 at 04:28 PM

This is the method im using...

code:
<?php
$data = file_get_contents("http://www.habbo.com.au/habbo_count_xml.action") or die("Could not get data");
$data = trim(strip_tags($data));
echo $data;
?>

is that correct?
RE: Include XML ? by absorbation on 04-17-2007 at 04:33 PM

That's fine for the the value you want. If you want to really dig into a RSS feed, PHP offers a variety of functions specific to the task.

Using your way is totally fine for what you are doing ;)

P.S: What are you using it for, it seems a little random [Image: zippydrogo.gif]


RE: Include XML ? by Eddie on 04-17-2007 at 04:46 PM

Official Habbo Australia Fansite, and im wanting to show how many Habbo's are online the hotel :) And thanks (Y)


RE: Include XML ? by Matti on 04-17-2007 at 04:47 PM

It's probably not the most recommended way, but in this case it should do. :)

A more 'professional' way, using regular expressions, would be:

code:
<?php
$data = file_get_contents("http://www.habbo.com.au/habbo_count_xml.action") or die("Could not get data");
$usercount = preg_replace("/<usercount>([0-9]+)<\\/usercount>/", "\\1", $data);
echo $data;
?>
Or, if your server has PHP 5 or higher installed, you can use the SimpleXML functions or the XML Reader object to read the XML file.

EDIT: Am I really that slow or are you too fast? :S
RE: Include XML ? by L. Coyote on 04-17-2007 at 04:55 PM

quote:
Originally posted by Mattike
if your server has PHP 5 or higher
Why? You can parse XML easily with PHP 4.

However, if the XML gives a very simple output, the strip_tags function is all he needs.
RE: Include XML ? by Eddie on 04-17-2007 at 04:59 PM

quote:
Originally posted by L. Coyote
quote:
Originally posted by Mattike
if your server has PHP 5 or higher
Why? You can parse XML easily with PHP 4.

However, if the XML gives a very simple output, the strip_tags function is all he needs.
And thats what im using, and it works fine, just takes a while to collect it so i've taken it down temporarily :(