⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xml_domit_xpath.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 3 页
字号:
				}				else if (strpos($expression, '<') !== false) {					$expression = str_replace('@', ('floatval($' . "contextNode->getAttribute('"), $expression);					$expression = str_replace('<', "')) < floatval(", $expression);					if (!is_numeric($expression)) $expression = str_replace('floatval', '', $expression);					$expression .= ')';				}				else {					$expression = str_replace('@', ('$' . "contextNode->hasAttribute('"), $expression);					$expression.= "')";				}			}			else {				if (strpos($expression, '>=') !== false) {					$signPos = strpos($expression, '>=');					$elementName = trim(substr($expression, 0, $signPos));					$elementValue = trim(substr($expression, ($signPos + 2)));					$expression = '$' . "this->hasNamedChildElementGreaterThanOrEqualToValue(" .									'$' . "contextNode, '" . $elementName . "', " .									$elementValue . ')';				}				else if (strpos($expression, '<=') !== false) {					$signPos = strpos($expression, '>=');					$elementName = trim(substr($expression, 0, $signPos));					$elementValue = trim(substr($expression, ($signPos + 2)));					$expression = '$' . "this->hasNamedChildElementLessThanOrEqualToValue(" .									'$' . "contextNode, '" . $elementName . "', " .									$elementValue . ')';				}				else if (strpos($expression, '!=') !== false) {					$signPos = strpos($expression, '>=');					$elementName = trim(substr($expression, 0, $signPos));					$elementValue = trim(substr($expression, ($signPos + 2)));					$expression = '$' . "this->hasNamedChildElementNotEqualToValue(" .									'$' . "contextNode, '" . $elementName . "', " .									$elementValue . ')';				}				else if (strpos($expression, '=') !== false) {					$signPos = strpos($expression, '=');					$elementName = trim(substr($expression, 0, $signPos));					$elementValue = trim(substr($expression, ($signPos + 1)));					$expression = '$' . "this->hasNamedChildElementEqualToValue(" .									'$' . "contextNode, '" . $elementName . "', " .									$elementValue . ')';				}				else if (strpos($expression, '>') !== false) {					$signPos = strpos($expression, '=');					$elementName = trim(substr($expression, 0, $signPos));					$elementValue = trim(substr($expression, ($signPos + 1)));					$expression = '$' . "this->hasNamedChildElementGreaterThanValue(" .									'$' . "contextNode, '" . $elementName . "', " .									$elementValue . ')';				}				else if (strpos($expression, '<') !== false) {					$signPos = strpos($expression, '=');					$elementName = trim(substr($expression, 0, $signPos));					$elementValue = trim(substr($expression, ($signPos + 1)));					$expression = '$' . "this->hasNamedChildElementLessThanValue(" .									'$' . "contextNode, '" . $elementName . "', " .									$elementValue . ')';				}				else {					$expression = '$' . "this->hasNamedChildElement(" .									'$' . "contextNode, '" . $expression . "')";				}			}		}		return $expression;	} //expressionToPHP	/**	* Selects nodes that match the predicate expression	* @param string The predicate expression, formatted as a PHP expression	*/	function filterByPHPExpression($expression) {		if (count($this->globalNodeContainer) != 0) {			foreach ($this->globalNodeContainer as $key =>$value) {				$contextNode =& $this->globalNodeContainer[$key];				if ($contextNode->nodeType == DOMIT_ELEMENT_NODE) {					$evaluatedExpression = 'if (' . $expression . ") $" .									'this->localNodeContainer[] =& $' . 'contextNode;';					eval($evaluatedExpression);				}			}		}	} //filterByPHPExpression	/**	* Selects nodes with child elements that match the specified name	* @param object The parent node of the child elements to match	* @param string The tag name to match on	* @return boolean True if a matching child element exists	*/	function hasNamedChildElement(&$parentNode, $nodeName) {		$total = $parentNode->childCount;		for ($i = 0; $i < $total; $i++) {			$currNode =& $parentNode->childNodes[$i];			if (($currNode->nodeType == DOMIT_ELEMENT_NODE) && ($currNode->nodeName == $nodeName)) {				return true;			}		}		return false;	} //hasNamedChildElement	/**	* Selects nodes with child elements that match the specified name and text value	* @param object The parent node of the child elements to match	* @param string The tag name to match on	* @param string The text string to match on	* @return boolean True if a matching child element exists	*/	function hasNamedChildElementEqualToValue(&$parentNode, $nodeName, $nodeValue) {		$total = $parentNode->childCount;		for ($i = 0; $i < $total; $i++) {			$currNode =& $parentNode->childNodes[$i];			if (($currNode->nodeType == DOMIT_ELEMENT_NODE) &&				($currNode->nodeName == $nodeName) && ($currNode->getText() == $nodeValue)) {				return true;			}		}		return false;	} //hasNamedChildElementEqualToValue	/**	* Selects nodes with child elements that are greater than or equal to the specified name and value	* @param object The parent node of the child elements to match	* @param string The tag name to match on	* @param string The text string to match on	* @return boolean True if a matching child element exists	*/	function hasNamedChildElementGreaterThanOrEqualToValue(&$parentNode, $nodeName, $nodeValue) {		$isNumeric = false;		if (is_numeric($nodeValue)) {			$isNumeric = true;			$nodeValue = floatval($nodeValue);		}		$total = $parentNode->childCount;		for ($i = 0; $i < $total; $i++) {			$currNode =& $parentNode->childNodes[$i];			if (($currNode->nodeType == DOMIT_ELEMENT_NODE) && ($currNode->nodeName == $nodeName)) {				if ($isNumeric) {$compareVal = floatval($currNode->getText());}				else {$compareVal = $currNode->getText();}				if ($compareVal >= $nodeValue) return true;			}		}		return false;	} //hasNamedChildElementGreaterThanOrEqualToValue	/**	* Selects nodes with child elements that are less than or equal to the specified name and value	* @param object The parent node of the child elements to match	* @param string The tag name to match on	* @param string The text string to match on	* @return boolean True if a matching child element exists	*/	function hasNamedChildElementLessThanOrEqualToValue(&$parentNode, $nodeName, $nodeValue) {		$isNumeric = false;		if (is_numeric($nodeValue)) {			$isNumeric = true;			$nodeValue = floatval($nodeValue);		}		$total = $parentNode->childCount;		for ($i = 0; $i < $total; $i++) {			$currNode =& $parentNode->childNodes[$i];			if (($currNode->nodeType == DOMIT_ELEMENT_NODE) && ($currNode->nodeName == $nodeName)) {				if ($isNumeric) {$compareVal = floatval($currNode->getText());}				else {$compareVal = $currNode->getText();}				if ($compareVal <= $nodeValue) return true;			}		}		return false;	} //hasNamedChildElementLessThanOrEqualToValue	/**	* Selects nodes with child elements that are not equal to the specified name and value	* @param object The parent node of the child elements to match	* @param string The tag name to match on	* @param string The text string to match on	* @return boolean True if a matching child element exists	*/	function hasNamedChildElementNotEqualToValue(&$parentNode, $nodeName, $nodeValue) {		$isNumeric = false;		if (is_numeric($nodeValue)) {			$isNumeric = true;			$nodeValue = floatval($nodeValue);		}		$total = $parentNode->childCount;		for ($i = 0; $i < $total; $i++) {			$currNode =& $parentNode->childNodes[$i];			if (($currNode->nodeType == DOMIT_ELEMENT_NODE) && ($currNode->nodeName == $nodeName)) {				if ($isNumeric) {$compareVal = floatval($currNode->getText());}				else {$compareVal = $currNode->getText();}				if ($compareVal != $nodeValue) return true;			}		}		return false;	} //hasNamedChildElementNotEqualToValue		/**	* Selects nodes with child elements that are greater than the specified name and value	* @param object The parent node of the child elements to match	* @param string The tag name to match on	* @param string The text string to match on	* @return boolean True if a matching child element exists	*/	function hasNamedChildElementGreaterThanValue(&$parentNode, $nodeName, $nodeValue) {		$isNumeric = false;		if (is_numeric($nodeValue)) {			$isNumeric = true;			$nodeValue = floatval($nodeValue);		}		$total = $parentNode->childCount;		for ($i = 0; $i < $total; $i++) {			$currNode =& $parentNode->childNodes[$i];			if (($currNode->nodeType == DOMIT_ELEMENT_NODE) && ($currNode->nodeName == $nodeName)) {				if ($isNumeric) {$compareVal = floatval($currNode->getText());}				else {$compareVal = $currNode->getText();}				if ($compareVal > $nodeValue) return true;			}		}		return false;	} //hasNamedChildElementGreaterThanValue	/**	* Selects nodes with child elements that are less than the specified name and value	* @param object The parent node of the child elements to match	* @param string The tag name to match on	* @param string The text string to match on	* @return boolean True if a matching child element exists	*/	function hasNamedChildElementLessThanValue(&$parentNode, $nodeName, $nodeValue) {		$isNumeric = false;		if (is_numeric($nodeValue)) {			$isNumeric = true;			$nodeValue = floatval($nodeValue);		}		$total = $parentNode->childCount;		for ($i = 0; $i < $total; $i++) {			$currNode =& $parentNode->childNodes[$i];			if (($currNode->nodeType == DOMIT_ELEMENT_NODE) && ($currNode->nodeName == $nodeName)) {				if ($isNumeric) {$compareVal = floatval($currNode->getText());}				else {$compareVal = $currNode->getText();}				if ($compareVal < $nodeValue) return true;			}		}		return false;	} //hasNamedChildElementLessThanValue	/**	* Selects named elements of the specified index	* @param string The pattern segment containing the node expression	* @param int The index (base 1) of the matching node	* @param boolean True if the selection is to be performed recursively	*/	function refilterByIndex($index) {		if ($index > 1) {			if (count($this->globalNodeContainer) != 0) {				$counter = 0;				$lastParentID = null;				foreach ($this->globalNodeContainer as $key =>$value) {					$currNode =& $this->globalNodeContainer[$key];					if (($lastParentID != null) && ($currNode->parentNode->uid != $lastParentID)) {						$counter = 0;					}					$counter++;					if (($counter == $index) && ($currNode->parentNode->uid == $lastParentID)) {						$this->localNodeContainer[] =& $currNode;					}					$lastParentID = $currNode->parentNode->uid;				}			}		}		else {			$this->localNodeContainer =& $this->globalNodeContainer;		}	} //refilterByIndex	/**	* Selects named elements of the specified index	* @param string The pattern segment containing the node expression	* @param int The index (base 1) of the matching node	* @param boolean True if the selection is to be performed recursively	*/	function filterByIndex($nodeName, $index, $deep) {		if (count($this->globalNodeContainer) != 0) {			foreach ($this->globalNodeContainer as $key =>$value) {				$currNode =& $this->globalNodeContainer[$key];				$this->_filterByIndex($currNode, $nodeName, $index, $deep);			}		}	} //filterByIndex	/**	* Selects named elements of the specified index	* @param object The context node	* @param string The pattern segment containing the node expression	* @param int The index (base 1) of the matching node	* @param boolean True if the selection is to be performed recursively	*/	function _filterByIndex(&$contextNode, $nodeName, $index, $deep) {		if (($contextNode->nodeType == DOMIT_ELEMENT_NODE) ||			($contextNode->nodeType == DOMIT_DOCUMENT_NODE)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -