07-20-2011, 09:00 AM
[eluser]Doseone[/eluser]
I’m trying to get pagination to work with simpleXML but struggling to get anywhere.
my xml
model php
controller php
veiw php
I’m trying to get pagination to work with simpleXML but struggling to get anywhere.
my xml
Code:
<?xml version="1.0" ?>
<companies>
<company>
<logo>http://www.pathtourl/logo.png</logo>
<name>Company Name</name>
<description>company description</description>
</company>
</companies>
model php
Code:
function list_companies($xml_file) {
$xml = simplexml_load_file($xml_file);
$data = $xml->xpath('company');
return $data;
}
controller php
Code:
public function index() {
$data['companies'] = $this->companies_model->list_companies($data['companies_xml']);
$this->load->view('companies_widget',$data);
}
veiw php
Code:
<?php foreach($companies as $row): ?>
<article class="company">
<img >logo;?>" alt="" class="left"/>
<div class="details left">
<h3><?=$row->name;?></h3>
<?=$row->description;?>
</div>
</article>
<?php endforeach;?>