Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <pre>
- <?php
- $x = new xml_adapter("newfeed.xml");
- class xml_adapter{
- function __construct($xml_file){
- $xml_org = simplexml_load_file("newfeed.xml");
- $i = 0;
- foreach($xml_org->children() as $a => $xml) {
- //echo $a. "=" .$b ."\n";
- $business[$i]["opening_times"] = $this->get_hours($xml->hours);
- $business[$i]["events"] = $this->get_events($xml->events);
- $business[$i]["pictures"] = $this->get_pictures($xml->pics);
- $business[$i]["teams"] = $this->get_teams($xml->teams);
- $business[$i]["packages"] = $this->get_packages($xml->packages);
- $business[$i]["menus"] = $this->get_menus($xml->menus);
- $business[$i]["social"] = $this->get_social($xml->social);
- $business[$i]["info"] = $this->get_info($xml);
- $business[$i]["phones"] = $this->get_phones($xml);
- $business[$i]["account"] = $this->get_account($xml);
- $i++;
- }
- print_r($business);
- }
- function get_phones($xml){
- $attr['main_phone'] = (string)$xml->phone[0];
- return $attr;
- }
- function get_account($xml){
- $attr["id"] = (string)$xml->accountId;
- $attr["number"] = (string)$xml->accountNumber;
- $attr["businessName"] = (string)$xml->businessName;
- $attr["timeZone"] = (string)$xml->timeZone;
- $attr["description"] = (string)$xml->description;
- return $attr;
- }
- function get_info($xml){
- $attr['cuisine'] = (string)$xml->cuisine;
- $attr['specialty'] = (string)$xml->specialty;
- $attr['mealsFeatured'] = (string)$xml->mealsFeatured;
- $attr['alcoholFeatured'] = (string)$xml->alcoholFeatured;
- $attr['delivery'] = (string)$xml->delivery;
- $attr['takeOut'] = (string)$xml->takeOut;
- $attr['reservations'] = (string)$xml->reservations;
- $attr['payment'] = (string)$xml->payment;
- $attr['wiFi'] = (string)$xml->wiFi;
- $attr['numberOfTvs'] = (string)$xml->numberOfTvs;
- $attr['dressCode'] = (string)$xml->dressCode;
- $attr['capacity'] = (string)$xml->capacity;
- $attr['catering'] = (string)$xml->catering;
- $attr['guestBartending'] = (string)$xml->guestBartending;
- $attr['privateRooms'] = (string)$xml->privateRooms;
- $attr['privateEventPartyRooms'] = (string)$xml->privateEventPartyRooms;
- $attr['emailForEvents'] = (string)$xml->emailForEvents;
- $attr['sisterLocation'] = (string)$xml->sisterLocation;
- $attr['awardsPress'] = (string)$xml->awardsPress;
- $attr['publisher_url'] = (string)$xml->publisher_url;
- return $attr;
- }
- function get_social($xml){
- $attr[facebook][url] = (string)$xml->facebookURL[0];
- $attr[twitter][url] = (string)$xml->twitterURL[0];
- return $attr;
- }
- function get_teams($xml){
- $attr=array();
- $i=0;
- foreach($xml->children() as $a => $b) {
- $attr[$i] = (string)$b;
- $i++;
- }
- return $attr;
- }
- function get_menus($xml){
- $attr=array();
- $i=0;
- foreach($xml->children() as $a => $b) {
- $attr[$i] = (string)$b;
- $i++;
- }
- return $attr;
- }
- function get_packages($xml){
- $attr=array();
- $i=0;
- foreach($xml->children() as $a => $b) {
- $attr[$i] = (string)$b;
- $i++;
- }
- return $attr;
- }
- function get_pictures($xml){
- $attr=array();
- $i=0;
- foreach($xml->children() as $a => $b) {
- $attr[$i]['url'] = (string)$b;
- $i++;
- }
- return $attr;
- }
- function get_hours($xml){
- $attr=array();
- $i=0;
- $attr["mon"]["start"] = (string)$xml->startMonHours;
- $attr["mon"]["end"] = (string)$xml->endMonHours;
- $attr["tue"]["start"] = (string)$xml->startTueHours[0];
- $attr["tue"]["end"] = (string)$xml->endTueHours[0];
- $attr["wed"]["start"] = (string)$xml->startWedHours[0];
- $attr["wed"]["end"] = (string)$xml->endWedHours[0];
- $attr["thu"]["start"] = (string)$xml->startThuHours[0];
- $attr["thu"]["end"] = (string)$xml->endThuHours[0];
- $attr["fri"]["start"] = (string)$xml->startFriHours[0];
- $attr["fri"]["end"] = (string)$xml->endFriHours[0];
- $attr["sat"]["start"] = (string)$xml->startSatHours[0];
- $attr["sat"]["end"] = (string)$xml->endSatHours[0];
- $attr["sun"]["start"] = (string)$xml->startSunHours[0];
- $attr["sun"]["end"] = (string)$xml->endSunHours[0];
- return $attr;
- }
- function get_events($xml){
- $attr=array();
- $i=0;
- foreach($xml->recurring->children() as $a => $b) {
- $attr['recurring'][$i] = array();
- eval('foreach($xml->recurring->'.$a.'[0]->attributes() as $x => $y) { $attr["recurring"][$i][(string)$x] = (string)$y[0];}');
- $attr['recurring'][$i]['desc'] = (string)$b;
- $i++;
- }
- $i=0;
- foreach($xml->one_time->children() as $a => $b) {
- $attr['once'][$i] = array();
- eval('foreach($xml->one_time->'.$a.'[0]->attributes() as $x => $y) { $attr["once"][$i][(string)$x] = (string)$y[0];}');
- $attr['once'][$i]['desc'] = (string)$b;
- $i++;
- }
- return $attr;
- }
- }
Add Comment
Please, Sign In to add comment