I have a code like:
<?php
class Files {
protected function get() {
return array(
'files' => array(
'file' => array(
array(
'filename' => 'test1.jpg',
'modified' => '2015-01-01 00:00:00',
),
array(
'filename' => 'test2.jpg',
'modified' => '2015-01-02 00:00:00',
),
array(
'filename' => 'test3.jpg',
'modified' => '2015-01-03 00:00:00',
),
),
)
);
}
}
JSON Output:
{
"files": {
"file": [
{
"filename": "test1.jpg",
"modified": "2015-01-01 00:00:00"
},
{
"filename": "test2.jpg",
"modified": "2015-01-02 00:00:00"
},
{
"filename": "test3.jpg",
"modified": "2015-01-03 00:00:00"
}
]
}
}
XML output:
<response>
<files>
<file>
<item>
<filename>test1.jpg</filename>
<modified>2015-01-01 00:00:00</modified>
</item>
<item>
<filename>test2.jpg</filename>
<modified>2015-01-02 00:00:00</modified>
</item>
<item>
<filename>test3.jpg</filename>
<modified>2015-01-03 00:00:00</modified>
</item>
</file>
</files>
</response>
The problem is that I want the files to be in tags <file>, not in tags <item>.
Here is an example of the XML output I would like to receive:
<response>
<files>
<file>
<filename>test1.jpg</filename>
<modified>2015-01-01 00:00:00</modified>
</file>
<file>
<filename>test2.jpg</filename>
<modified>2015-01-02 00:00:00</modified>
</file>
<file>
<filename>test3.jpg</filename>
<modified>2015-01-03 00:00:00</modified>
</file>
</files>
</response>
How can i achieve this? I tried almost everything I could come up with, no luck.
I tried the following answer, but that did not help. I assume the answer is for Restler 1 or 2, since it is so old:
Luracast Restler: "Naming" returned objects
EDIT:
Changing XmlFormat::$defaultTagName = 'file';or something like that is not an option, since I need to rename other tags <item>also in the same request.
EDIT 2:
, "XmlFormat.php" , , , ( : Luracast Restler: "" ) ?