Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <responseITEMs xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <ITEMs>
- <ITEM libraryid="e3712df592253fcb4" featured="false" releasedate="2017-24-01 00:00:00" code="ABC001" detail="Some text" name="Dummy One" displaytitle="Dummy One" keywords="" id="1fef760bc1d61c8c" status="active" lastupdated="2016-24-01 04:53:28"/>
- <ITEM libraryid="e3712df592253fcb4" featured="false" releasedate="2017-24-01 00:00:00" code="ABC003" detail="Some text" name="Dummy Three" displaytitle="Dummy Three" keywords="" id="3e35wba1d9b32a45" status="active" lastupdated="2016-24-01 04:53:15"/>
- <ITEM libraryid="e3712df592253fcb4" featured="false" releasedate="2017-24-01 00:00:00" code="ABC002" detail="Some text" name="Dummy Two" displaytitle="Dummy Two" keywords="" id="cca6f0cab9defe80" status="active" lastupdated="2017-24-01 01:57:37"/>
- </ITEMs>
- </responseITEMs>
- $Json = json_encode(simplexml_load_string($data));
- echo $Json;
- ITEMs: {
- ITEM: [
- {
- @attributes: {
- libraryid: "e3712df592253fcb4",
- featured: "false",
- releasedate: "2017-24-01 00:00:00",
- code: "ABC001",
- detail: "Some text",
- name: "Dummy One",
- displaytitle: "Dummy One",
- keywords: "",
- id: "1fef760bc1d61c8c",
- status: "active",
- trackcount: "0",
- lastupdated: "2016-24-01 04:53:28"
- }
- },
- {
- @attributes: {..... etc
- import DS from 'ember-data';
- export default DS.RESTSerializer.extend({
- normalizeResponse(store, primaryModelClass, payload, id, requestType) {
- payload = {
- ITEM: {
- id: payload.ITEMs.ITEM[0]["@attributes"].id,
- type: requestType.modelName,
- name: payload.ITEMs.ITEM[0]["@attributes"].name
- }
- };
- return this._super(store, primaryModelClass, payload, id, requestType);
- }
- });
- export default Ember.Route.extend({
- model() {
- return this.store.findAll('ITEM');
- }
- });
- export default DS.Model.extend({
- name: DS.attr('string'),
- });
- <strong>{{ model.name }}</strong>
- <ul>
- {{#each model.ITEM as |one|}}
- <li>{{one.name}}</li>
- {{/each}}
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement