<xml>
−
<item>
<userid>1</userid>
<username>example</username>
<useremail>example@gmail.com</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
开发者_StackOverflow中文版if($query->num_rows()>0){
foreach($query->result()as $row){
$data[] = $row;
}
return $data;
}
thanks
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>example@gmail.com</email>
</item>
<item>
<id>2</id>
<name>example2</name>
<email>example2@gmail.com</email>
</item>
</users>
精彩评论