Server : Apache/2.4.41 (Ubuntu) System : Linux journalup 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/lib/pkp/classes/xml/ |
<?php /** * @file classes/xml/XMLParserDOMHandler.inc.php * * Copyright (c) 2014-2020 Simon Fraser University * Copyright (c) 2000-2020 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class XMLParserDOMHandler * @ingroup xml * @see XMLParser * * @brief Default handler for XMLParser returning a simple DOM-style object. * This handler parses an XML document into a tree structure of XMLNode objects. * */ import('lib.pkp.classes.xml.XMLNode'); class XMLParserDOMHandler extends XMLParserHandler { /** @var XMLNode reference to the root node */ var $rootNode; /** @var XMLNode reference to the node currently being parsed */ var $currentNode; /** @var reference to the current data */ var $currentData; /** * Constructor. */ function __construct() { $this->rootNodes = array(); $this->currentNode = null; } function destroy() { unset($this->currentNode, $this->currentData, $this->rootNode); } /** * Callback function to act as the start element handler. * @param $parser XMLParser * @param $tag string * @param $attributes array */ function startElement($parser, $tag, $attributes) { $this->currentData = null; $node = new XMLNode($tag); $node->setAttributes($attributes); if (isset($this->currentNode)) { $this->currentNode->addChild($node); $node->setParent($this->currentNode); } else { $this->rootNode =& $node; } $this->currentNode =& $node; } /** * Callback function to act as the end element handler. * @param $parser XMLParser * @param $tag string */ function endElement($parser, $tag) { $this->currentNode->setValue($this->currentData); $this->currentNode =& $this->currentNode->getParent(); $this->currentData = null; } /** * Callback function to act as the character data handler. * @param $parser XMLParser * @param $data string */ function characterData($parser, $data) { $this->currentData .= $data; } /** * Returns a reference to the root node of the tree representing the document. * @return XMLNode */ function getResult() { return $this->rootNode; } }