Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

joomla xml parser module

Posted on 2011-03-08
5
Medium Priority
?
959 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:Mutsop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Author Comment

by:Mutsop
ID: 35080449
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?
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 35099490
Visit this URL in a regular web browser and use "view source" to see the XML:
http://eu.riftgame.com/en/status/eu-status.xml

As you will quickly see the <status> tag has <shard> tags with lots of attributes, but nowhere will you find a tag that would generate $obj->price as used on line 26 of the code snippet.
0
 
LVL 3

Author Comment

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


thanks
0
 
LVL 3

Author Closing Comment

by:Mutsop
ID: 35099702
thanks
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35101248
Thanks for the points and please don't feel bad about it - we've all done something like that!  All the best, ~Ray
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
There is a massive demand for content on the web right now, and it doesn't look like it's going to stop any time soon. But, if you are running a business blog, it's not just enough to offer your audience lots of content. It needs to be high-quality…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 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