Link to home
Start Free TrialLog in
Avatar of Mutsop
MutsopFlag for Belgium

asked on

joomla xml parser module

Hi,

I've been searching for a while and can't seem to find a way to actually create a joomla 1.6 module (xml parser).
I actually need to retrieve information from this xml: link

fyi only from one of these servers I need to retrieve information, not all of them.

How do I proceed? Also how should I put this in a module for joomla 1.6?

regards
Avatar of Mutsop
Mutsop
Flag of Belgium image

ASKER

k so I actually started on my own... but came onto a little problem:

It's the first time I'm trying to build a module for joomla 1.6.
So to ease my work I just copied the basic of the rss feed module.

Now, I'm trying to read an xml file (from an url) and show these information on my website.

So here is the code (I suppose you don't really need the default.php and xml of the options).

mod_xmlreader.php:
<?php
// no direct access
defined('_JEXEC') or die;

// Include the syndicate functions only once
require_once dirname(__FILE__).DS.'helper.php';

$status = modXmlreaderHelper::getStatus($params);
require JModuleHelper::getLayoutPath('mod_xmlreader');

Open in new window


helper.php:
<?php
// no direct access
defined('_JEXEC') or die;

class modXmlreaderHelper
{
	static function getStatus()
	{
		error_reporting(E_ALL);
		echo "<pre>" . PHP_EOL;

		// TEST DATA FROM THE POST AT EE
		$url = "http://eu.riftgame.com/en/status/eu-status.xml";

		// READ THE EXTERNAL DATA
		$xml = file_get_contents($url);

		// MAKE AN OBJECT
		$obj = SimpleXML_Load_String($xml);

		// ACTIVATE THIS TO SEE THE OBJECT
		// var_dump($obj);

		// PROCESS THE OBJECT ELEMENTS INTO AN ARRAY
		$status = array();
		foreach ($obj->price as $thing)
		{
			array_push($status,(string)$thing);
		}

		// SHOW THE WORK PRODUCT
		print_r($status);
		//return $status;
	}
}

Open in new window


So as you can see, I'm using a print_r to see the result of my array.
But as my title says, its empty :(

Any ideas why?
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mutsop

ASKER

ooow.... this is kinda embaracing :(
This is what happens when you copy paste and dont check the code twice :)


thanks
Avatar of Mutsop

ASKER

thanks
Thanks for the points and please don't feel bad about it - we've all done something like that!  All the best, ~Ray