views:

40

answers:

1
<xml>
−
<item>
<userid>1</userid>
<username>example</username>
<useremail>[email protected]</useremail>
</item>
</xml>

hi all,im new to CI,just want to know how to change <item> to something else.maybe <user>

here is my model

if($query->num_rows()>0){
foreach($query->result()as $row){
$data[] = $row;
}
return $data;
}

thanks

+1  A: 

is used for arrays instead of numerical indexes (that would not work well for anyone).

As the is a generic function for converting any kind of array or object to valid XML there will of course be difficulties creating nice syntax with specific names.

The word "item" is chucked in on line 485:

$key = "item";

You can hack it, or try to think up a nice solution for this. I'm happy to include any god solution, but right now I'm in San Francisco for the EECI2010 (ExpressionEngine and CodeIgniter) conference so not going to try and think anything up now. :-)

You could format your array different so you get:

<xml>
<users>
    <item>
        <id>1</id>
        <name>example</name>
        <email>[email protected]</email>
    </item>
    <item>
        <id>2</id>
        <name>example2</name>
        <email>[email protected]</email>
    </item>
</users>
Phil Sturgeon