Welcome Guest, Not a member yet? Register   Sign In
simpleXML pagination
#1

[eluser]Doseone[/eluser]
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:
&lt;?php foreach($companies as $row): ?&gt;
    
    <article class="company">
        <img >logo;?&gt;" alt="" class="left"/>
        <div class="details left">
            <h3>&lt;?=$row->name;?&gt;</h3>
            &lt;?=$row->description;?&gt;
        </div>
    </article>

    &lt;?php endforeach;?&gt;
#2

[eluser]Aken[/eluser]
You're likely retrieving the wrong part of your SimpleXML element. Play around with your list_companies() model function until it returns the data that you want (an array).




Theme © iAndrew 2016 - Forum software by © MyBB