Guest User

Untitled

a guest
Aug 14th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. <pre>
  2. <?php
  3.  
  4.  
  5. $x = new xml_adapter("newfeed.xml");
  6.  
  7.  
  8.  
  9. class xml_adapter{
  10.  
  11. function __construct($xml_file){
  12.  
  13. $xml_org = simplexml_load_file("newfeed.xml");
  14.  
  15.  
  16. $i = 0;
  17. foreach($xml_org->children() as $a => $xml) {
  18. //echo $a. "=" .$b ."\n";
  19.  
  20. $business[$i]["opening_times"] = $this->get_hours($xml->hours);
  21. $business[$i]["events"] = $this->get_events($xml->events);
  22. $business[$i]["pictures"] = $this->get_pictures($xml->pics);
  23. $business[$i]["teams"] = $this->get_teams($xml->teams);
  24. $business[$i]["packages"] = $this->get_packages($xml->packages);
  25. $business[$i]["menus"] = $this->get_menus($xml->menus);
  26. $business[$i]["social"] = $this->get_social($xml->social);
  27. $business[$i]["info"] = $this->get_info($xml);
  28. $business[$i]["phones"] = $this->get_phones($xml);
  29. $business[$i]["account"] = $this->get_account($xml);
  30. $i++;
  31. }
  32.  
  33. print_r($business);
  34.  
  35. }
  36.  
  37. function get_phones($xml){
  38.  
  39. $attr['main_phone'] = (string)$xml->phone[0];
  40. return $attr;
  41.  
  42. }
  43.  
  44. function get_account($xml){
  45.  
  46. $attr["id"] = (string)$xml->accountId;
  47. $attr["number"] = (string)$xml->accountNumber;
  48. $attr["businessName"] = (string)$xml->businessName;
  49. $attr["timeZone"] = (string)$xml->timeZone;
  50. $attr["description"] = (string)$xml->description;
  51.  
  52. return $attr;
  53.  
  54.  
  55. }
  56.  
  57.  
  58. function get_info($xml){
  59.  
  60. $attr['cuisine'] = (string)$xml->cuisine;
  61. $attr['specialty'] = (string)$xml->specialty;
  62. $attr['mealsFeatured'] = (string)$xml->mealsFeatured;
  63. $attr['alcoholFeatured'] = (string)$xml->alcoholFeatured;
  64. $attr['delivery'] = (string)$xml->delivery;
  65. $attr['takeOut'] = (string)$xml->takeOut;
  66. $attr['reservations'] = (string)$xml->reservations;
  67. $attr['payment'] = (string)$xml->payment;
  68. $attr['wiFi'] = (string)$xml->wiFi;
  69. $attr['numberOfTvs'] = (string)$xml->numberOfTvs;
  70. $attr['dressCode'] = (string)$xml->dressCode;
  71. $attr['capacity'] = (string)$xml->capacity;
  72. $attr['catering'] = (string)$xml->catering;
  73. $attr['guestBartending'] = (string)$xml->guestBartending;
  74. $attr['privateRooms'] = (string)$xml->privateRooms;
  75. $attr['privateEventPartyRooms'] = (string)$xml->privateEventPartyRooms;
  76. $attr['emailForEvents'] = (string)$xml->emailForEvents;
  77. $attr['sisterLocation'] = (string)$xml->sisterLocation;
  78. $attr['awardsPress'] = (string)$xml->awardsPress;
  79. $attr['publisher_url'] = (string)$xml->publisher_url;
  80.  
  81. return $attr;
  82.  
  83. }
  84.  
  85. function get_social($xml){
  86.  
  87. $attr[facebook][url] = (string)$xml->facebookURL[0];
  88. $attr[twitter][url] = (string)$xml->twitterURL[0];
  89.  
  90. return $attr;
  91. }
  92.  
  93. function get_teams($xml){
  94.  
  95. $attr=array();
  96. $i=0;
  97. foreach($xml->children() as $a => $b) {
  98.  
  99. $attr[$i] = (string)$b;
  100. $i++;
  101. }
  102.  
  103. return $attr;
  104. }
  105.  
  106.  
  107.  
  108. function get_menus($xml){
  109. $attr=array();
  110. $i=0;
  111. foreach($xml->children() as $a => $b) {
  112.  
  113. $attr[$i] = (string)$b;
  114. $i++;
  115. }
  116.  
  117. return $attr;
  118.  
  119. }
  120.  
  121. function get_packages($xml){
  122.  
  123. $attr=array();
  124. $i=0;
  125. foreach($xml->children() as $a => $b) {
  126.  
  127. $attr[$i] = (string)$b;
  128. $i++;
  129. }
  130.  
  131. return $attr;
  132.  
  133. }
  134.  
  135. function get_pictures($xml){
  136.  
  137.  
  138. $attr=array();
  139. $i=0;
  140. foreach($xml->children() as $a => $b) {
  141.  
  142. $attr[$i]['url'] = (string)$b;
  143. $i++;
  144. }
  145.  
  146. return $attr;
  147.  
  148. }
  149.  
  150.  
  151. function get_hours($xml){
  152.  
  153. $attr=array();
  154. $i=0;
  155.  
  156. $attr["mon"]["start"] = (string)$xml->startMonHours;
  157. $attr["mon"]["end"] = (string)$xml->endMonHours;
  158. $attr["tue"]["start"] = (string)$xml->startTueHours[0];
  159. $attr["tue"]["end"] = (string)$xml->endTueHours[0];
  160. $attr["wed"]["start"] = (string)$xml->startWedHours[0];
  161. $attr["wed"]["end"] = (string)$xml->endWedHours[0];
  162. $attr["thu"]["start"] = (string)$xml->startThuHours[0];
  163. $attr["thu"]["end"] = (string)$xml->endThuHours[0];
  164. $attr["fri"]["start"] = (string)$xml->startFriHours[0];
  165. $attr["fri"]["end"] = (string)$xml->endFriHours[0];
  166. $attr["sat"]["start"] = (string)$xml->startSatHours[0];
  167. $attr["sat"]["end"] = (string)$xml->endSatHours[0];
  168. $attr["sun"]["start"] = (string)$xml->startSunHours[0];
  169. $attr["sun"]["end"] = (string)$xml->endSunHours[0];
  170.  
  171. return $attr;
  172.  
  173. }
  174.  
  175.  
  176. function get_events($xml){
  177.  
  178. $attr=array();
  179. $i=0;
  180. foreach($xml->recurring->children() as $a => $b) {
  181.  
  182. $attr['recurring'][$i] = array();
  183. eval('foreach($xml->recurring->'.$a.'[0]->attributes() as $x => $y) { $attr["recurring"][$i][(string)$x] = (string)$y[0];}');
  184.  
  185. $attr['recurring'][$i]['desc'] = (string)$b;
  186. $i++;
  187. }
  188.  
  189. $i=0;
  190. foreach($xml->one_time->children() as $a => $b) {
  191.  
  192. $attr['once'][$i] = array();
  193. eval('foreach($xml->one_time->'.$a.'[0]->attributes() as $x => $y) { $attr["once"][$i][(string)$x] = (string)$y[0];}');
  194.  
  195. $attr['once'][$i]['desc'] = (string)$b;
  196. $i++;
  197. }
  198.  
  199. return $attr;
  200.  
  201. }
  202. }
Add Comment
Please, Sign In to add comment