KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/simes/unused/fCMSBackend/includes/xpath/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/simes/unused/fCMSBackend/includes/xpath/xpath_php4.php
<?php

require_once './includes/classes/XPath.class.php';

Class FCMSXPath {
	var $xp;

	# ----- Std. functions

	function parse ($s, $fromFile = True) {
		$this->xp = new XPath ();
		$this->xp->setSkipWhiteSpaces (TRUE);

		$this->xp->setVerbose (0);

		if ($fromFile) $ok = $this->xp->importFromFile ($s);
		else $ok = $this->xp->importFromString ($s);

		$this->xp->setVerbose (1);

		return $ok;
	}

	function match ($xpath) {
		return $this->xp->match ($xpath);
	}

	function matchNode ($xpath) {
		$n = $this->match ($xpath);
		if (! $n) return $n;

		$ret = $n [0];
		return $ret;
	}

	// Just like match, but returns elment names.
	function matchNames ($xpath) {
		$ret = array ();
		$rs = $this->match ($xpath);

		foreach ($rs as $node) {
			$name = $this->getNodeName ($node);
			array_push ($ret, $name);
		}

		return $ret;
	}
	
	# ----- Node functions
	# They take either xpath or node object.

	function getNodeName ($n) {
		if (gettype ($n) == "string") $n = $this->matchNode ($n);
		if (! $n) return "";

		return $this->xp->nodeName ($n);
	}

	function getNodeValue ($n) {
		if (gettype ($n) == "string") $n = $this->matchNode ($n);
		if (! $n) return "";

		return $this->xp->getData ($n);
	}
	
	function getAttribute ($node, $attr) {
		if (gettype ($node) == "string") $node = $this->matchNode ($node);
		return $this->xp->getAttributes ($node, $attr);
	}

	# ----- Export
	
	// Accepts either node or xpath.
	function exportNodeAsXML ($n) {
		if (gettype ($n) == "string") $n = $this->matchNode ($n);
		if (! $n) return "";

		$ret = $this->xp->exportAsXml ($n);
		return $ret;
	}

	function exportTreeAsXML () {
		$ret = $this->xp->exportAsXml ("");
		return $ret;
	}

	function exportToFile ($file) {
		$this->xp->setVerbose (0);
		$ret = $this->xp->exportToFile ($file);
		$this->xp->setVerbose (1);

		return $ret;
	}


	# ----- Tree modification

	function createSingleChildNodeOf ($parent_xpath, $element) {
		$p = $this->matchNode ($parent_xpath);
		
		if (count ($this->xp->match ($p . '/' . $element)) != 0) return;

		return $this->xp->appendChild ($p, '<' . $element . '/>');
	}

	function appendChildNodeOf ($parent_xpath, $element) {
		$p = $this->matchNode ($parent_xpath);

		$ret = $this->xp->appendChild ($p, '<' . $element . '/>');

		if ($ret == FALSE) {
			$errtxt = $this->xp>getLastError ();
			$GLOBALS ['request']->debugvar ($errtxt, 'appendChildError');
		}

		return $ret;
	}

	function setAttribute ($node, $attr, $var) {
		if (gettype ($node) == "string") $node = $this->matchNode ($node);
		$this->xp->setAttribute ($node, $attr, $var);
	}

	function setNodeValue ($node, $value) {
		if (gettype ($node) == "string") $node = $this->matchNode ($node);

		$this->xp->replaceData ($node, $value);
	}
}


?>

Anon7 - 2021