• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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).


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.