當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XMLParser::getArray方法代碼示例

本文整理匯總了PHP中XMLParser::getArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP XMLParser::getArray方法的具體用法?PHP XMLParser::getArray怎麽用?PHP XMLParser::getArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XMLParser的用法示例。


在下文中一共展示了XMLParser::getArray方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parseXml

	public function parseXml() {

		global $global;
		require_once($global['approot']."inc/lib_uuid.inc");

		// save xml for debugging?
		if($global['debugAndSaveXmlToFile'] == true) {
			$filename = date("Y_md_H-i-s.".getMicrotimeComponent())."___".mt_rand().".xml"; // 2012_0402_17-50-33.454312___437849328789.xml
			$path = $global['debugAndSaveXmlToFilePath'].$filename;
			file_put_contents($path, $this->theString);
		}

		// is this a supported XML type?
		if(!in_array((string)trim($this->xmlFormat), $global['enumXmlFormats'])) {
			return (int)400;
		}

		//$a = xml2array($this->theString);
		$aa = new XMLParser();
		$aa->rawXML = $this->theString;
		$aa->parse();

		if($aa->getError()) {
			return (int)403; // error code for failed to parse xml
		}

		$a = $aa->getArray();

		// parse REUNITE4 XML
		if($this->xmlFormat == "REUNITE4") {

			$this->createUUID();
			$this->arrival_reunite = true;
			$this->given_name     = isset($a['person']['givenName'])  ? $a['person']['givenName']  : null;
			$this->family_name    = isset($a['person']['familyName']) ? $a['person']['familyName'] : null;
			$this->expiry_date    = isset($a['person']['expiryDate']) ? $a['person']['expiryDate'] : null;
			$this->opt_status     = isset($a['person']['status'])     ? $a['person']['status']     : null;
			$this->last_updated   = date('Y-m-d H:i:s');

			$datetime      = isset($a['person']['dateTimeSent']) ? $a['person']['dateTimeSent'] : null;
			$timezoneUTC   = new DateTimeZone("UTC");
			$timezoneLocal = new DateTimeZone(date_default_timezone_get());
			$datetime2     = new DateTime();
			$datetime2->setTimezone($timezoneUTC);
			$datetime2->setTimestamp(strtotime($datetime));
			$datetime2->setTimezone($timezoneLocal);
			$this->creation_time = $datetime2->format('Y-m-d H:i:s');

			$this->opt_gender     = isset($a['person']['gender'])       ? $a['person']['gender']       : null;
			$this->years_old      = isset($a['person']['estimatedAge']) ? $a['person']['estimatedAge'] : null;
			$this->minAge         = isset($a['person']['minAge'])       ? $a['person']['minAge']       : null;
			$this->maxAge         = isset($a['person']['maxAge'])       ? $a['person']['maxAge']       : null;
			$this->other_comments = isset($a['person']['note'])         ? $a['person']['note']         : null;

			// TEMP HACK KLUGE to stuff person location data into the person_status last_known_location field
			$kluge = "";
			$kluge .= isset($a['person']['location']['street1'])      ? $a['person']['location']['street1']."\n"      : "";
			$kluge .= isset($a['person']['location']['street2'])      ? $a['person']['location']['street2']."\n"      : "";
			$kluge .= isset($a['person']['location']['neighborhood']) ? $a['person']['location']['neighborhood']."\n" : "";
			$kluge .= isset($a['person']['location']['city'])         ? $a['person']['location']['city']."\n"         : "";
			$kluge .= isset($a['person']['location']['region'])       ? $a['person']['location']['region']."\n"       : "";
			$kluge .= isset($a['person']['location']['postalCode'])   ? $a['person']['location']['postalCode']."\n"   : "";
			$kluge .= isset($a['person']['location']['country'])      ? $a['person']['location']['country']."\n"      : "";
			if(trim($kluge) != "") {
				$this->last_seen = $kluge;
			}

			// only update the incident_id if not already set
			if($this->incident_id === null) {

				$q = "
					SELECT *
					FROM incident
					WHERE shortname = '".mysql_real_escape_string((string)$a['person']['eventShortname'])."';
				";
				$result = $this->db->Execute($q);
				if($result === false) { daoErrorLog(__FILE__, __LINE__, __METHOD__, __CLASS__, __FUNCTION__, $this->db->ErrorMsg(), "person get incident ((".$q."))"); }

				$this->incident_id = $result->fields["incident_id"];
			}

			if(isset($a['person']['photos']['photo'])) {
				foreach($a['person']['photos'] as $photo) {
					if(trim($photo['data']) != "") {
						$i = new personImage();
						$i->init();
						$i->p_uuid = $this->p_uuid;
						$i->fileContentBase64 = $photo['data'];
						if(isset($photo['tags'])) {
							foreach($photo['tags'] as $tag) {
								$t = new personImageTag();
								$t->init();
								$t->image_id = $i->image_id;
								$t->tag_x    = $tag['x'];
								$t->tag_y    = $tag['y'];
								$t->tag_w    = $tag['w'];
								$t->tag_h    = $tag['h'];
								$t->tag_text = $tag['text'];
								$i->tags[] = $t;
							}
//.........這裏部分代碼省略.........
開發者ID:bobrock,項目名稱:vesuvius,代碼行數:101,代碼來源:class.person.php


注:本文中的XMLParser::getArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。