当前位置: 首页>>代码示例>>PHP>>正文


PHP XMLParser::getError方法代码示例

本文整理汇总了PHP中XMLParser::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::getError方法的具体用法?PHP XMLParser::getError怎么用?PHP XMLParser::getError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLParser的用法示例。


在下文中一共展示了XMLParser::getError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ipl_core_load_xml

/**
 * Load the data from the response as xml
 *
 */
function ipl_core_load_xml($xmlDataString)
{
    global $ipl_core_error_code;
    global $ipl_core_error_msg;
    global $ipl_core_api_error_code;
    global $ipl_core_api_customer_message;
    global $ipl_core_api_merchant_message;
    switch (IPL_CORE_XML_PARSER) {
        case 'simpleXml':
            if (!function_exists('simplexml_load_string')) {
                $ipl_core_error_code = 15;
                $ipl_core_error_msg = 'simpleXml lib has not been loaded';
                return false;
            }
            $xml = simplexml_load_string($xmlDataString);
            if (!$xml) {
                $ipl_core_error_code = 10;
                $ipl_core_error_msg = 'Invalid XML reponse received';
                return false;
            } else {
                $attr = $xml->attributes();
                $ipl_core_api_error_code = (int) $attr->error_code;
                $ipl_core_api_customer_message = (string) $attr->customer_message;
                $ipl_core_api_merchant_message = (string) $attr->merchant_message;
            }
            break;
        case 'preg':
            $errorCode = ipl_core_get_xml_attribute_value('data', 'error_code', $xml);
            if ($errorCode === false) {
                return false;
            }
            if ($errorCode > 0) {
                $ipl_core_api_customer_message = ipl_core_get_xml_attribute_value('data', 'customer_message', $xml);
                $ipl_core_api_merchant_message = ipl_core_get_xml_attribute_value('data', 'merchant_message', $xml);
            }
            break;
        case 'xmlParser':
            $parser = new XMLParser($xmlDataString);
            if ($parser->Parse() == false) {
                $xmlError = $parser->getError();
                $ipl_core_error_code = 10;
                $ipl_core_error_msg = "Invalid XML reponse received: {$xmlError}";
                return false;
            }
            $xml = $parser->document;
            if (!$xml) {
                $ipl_core_error_code = 10;
                $ipl_core_error_msg = 'Invalid XML reponse received';
                return false;
            } else {
                $ipl_core_api_error_code = (int) $xml->tagAttrs['error_code'];
                $ipl_core_api_customer_message = ipl_core_decode((string) $xml->tagAttrs['customer_message']);
                $ipl_core_api_merchant_message = ipl_core_decode((string) $xml->tagAttrs['merchant_message']);
            }
            break;
        default:
            $ipl_core_error_code = 9;
            $ipl_core_error_msg = 'Unknown XML parser lib: ' . IPL_CORE_XML_PARSER;
            return false;
            break;
    }
    return $xml;
}
开发者ID:xiaoguizhidao,项目名称:bilderrahmen,代码行数:67,代码来源:ipl_xml_api.php

示例2: 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::getError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。