public function getxmlAction() { $note = '<?xml version="1.0" encoding="UTF-8"?>'; $note .= "<profile>"; $user_id = get_user_id(); $user_mapper = new Application_Model_UserMapper(); $info_mapper = new Application_Model_InfoMapper(); $follow_mapper = new Application_Model_FollowMapper(); $user_mapper->increaseView(); $user = $user_mapper->find($user_id); $user_info = $info_mapper->findAllByColumn('user_id', $user_id); $followed_numbers = $follow_mapper->getFollowersNumber($user_id); $profile = array(); $profile['profile'] = array(); $profile_array = array("basicInfo", "story", "education", "contacts", "links", "work"); foreach ($profile_array as $elem) { $profile[$elem] = array(); } if (!empty($user_info)) { foreach ($user_info as $info) { if ($info['category'] == CATEGORY_BASIC) { $profile['basicInfo'][] = array("title" => $info['title'], "value" => $info['value']); } elseif ($info['category'] == CATEGORY_CONTACTS) { $profile['contacts'][] = array("title" => $info['title'], "value" => $info['value']); } elseif ($info['category'] == CATEGORY_EDUCATION) { $profile['education'][] = array("title" => $info['title'], "value" => $info['value']); } elseif ($info['category'] == CATEGORY_LINKS) { $profile['links'][] = array("title" => $info['title'], "value" => $info['value']); } elseif ($info['category'] == CATEGORY_STORY) { $profile['story'][] = array("title" => $info['title'], "value" => $info['value']); } elseif ($info['category'] == CATEGORY_WORK) { $profile['work'][] = array("title" => $info['title'], "value" => $info['value']); } } } $note .= "<name>" . $user['username'] . "</name>"; $note .= "<about>" . $user['about'] . "</about>"; $note .= "<view>" . $user['view'] . "</view>"; $profile_path = get_profile_path($user_id); $note .= "<profilePic>" . $profile_path . "</profilePic>"; $cover_path = get_cover_path($user_id); $note .= "<cover>" . $cover_path . "</cover>"; $note .= "<people>"; $note .= "<followers>" . $followed_numbers . "</followers>"; $note .= "<followersPics>" . "</followersPics>"; $note .= "</people>"; $note .= "<places> <place>" . $user['place'] . "</place> </places>"; foreach ($profile_array as $category) { $note .= "<" . $category . ">"; foreach ($profile[$category] as $bInfo) { $note .= "<" . $bInfo["title"] . ">" . $bInfo['value'] . "</" . $bInfo["title"] . ">"; } $note .= "</" . $category . ">"; } $note .= "</profile>"; header("Content-type: text/xml"); $xml = new SimpleXMLElement($note); echo $xml->asXML(); exit; }