Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. <responseITEMs xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  2. <ITEMs>
  3. <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"/>
  4. <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"/>
  5. <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"/>
  6. </ITEMs>
  7. </responseITEMs>
  8.  
  9. $Json = json_encode(simplexml_load_string($data));
  10. echo $Json;
  11.  
  12. ITEMs: {
  13. ITEM: [
  14. {
  15. @attributes: {
  16. libraryid: "e3712df592253fcb4",
  17. featured: "false",
  18. releasedate: "2017-24-01 00:00:00",
  19. code: "ABC001",
  20. detail: "Some text",
  21. name: "Dummy One",
  22. displaytitle: "Dummy One",
  23. keywords: "",
  24. id: "1fef760bc1d61c8c",
  25. status: "active",
  26. trackcount: "0",
  27. lastupdated: "2016-24-01 04:53:28"
  28. }
  29. },
  30. {
  31. @attributes: {..... etc
  32.  
  33. import DS from 'ember-data';
  34. export default DS.RESTSerializer.extend({
  35. normalizeResponse(store, primaryModelClass, payload, id, requestType) {
  36. payload = {
  37. ITEM: {
  38. id: payload.ITEMs.ITEM[0]["@attributes"].id,
  39. type: requestType.modelName,
  40. name: payload.ITEMs.ITEM[0]["@attributes"].name
  41. }
  42. };
  43. return this._super(store, primaryModelClass, payload, id, requestType);
  44. }
  45. });
  46.  
  47. export default Ember.Route.extend({
  48. model() {
  49. return this.store.findAll('ITEM');
  50. }
  51. });
  52.  
  53. export default DS.Model.extend({
  54. name: DS.attr('string'),
  55. });
  56.  
  57. <strong>{{ model.name }}</strong>
  58.  
  59. <ul>
  60. {{#each model.ITEM as |one|}}
  61. <li>{{one.name}}</li>
  62. {{/each}}
  63. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement