Source for file XMLParser.php
Documentation is available at XMLParser.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: David Costa <gurugeek@php.net> |
// +----------------------------------------------------------------------+
// \$Id: XMLParser.php,v 1.1 2004/08/19 18:28:15 gurugeek Exp $ $
// more comments will be added soon. Alpha version of the XML parser
// to be possibly replaced by a proper parse or extension as suggested by
class DB_Sqlite_Tools_XMLParser {
public $ignoreList = array ();
public function __construct ($fh, $pos = 0 ) {
$this->strlen = strlen($this->str);
public function getNextElement ()
// the loop is so that if we are told to ignore a certain
// element, then we can continue on to the next one and
// obviously, if we're at EOF, then there are no more
if (feof($this->fh)) return false;
// read up to the first open bracket, storing what's
while (($c != '<') && !feof($this->fh)) {
// read up to the first close bracket that isn't within
// quote marks, storing what's in between.
while (($c != '>') // end if $c == '>'
|| ($inQuote) // unless this is within a quote,
|| (feof($this->fh)) // or if we have reached EOF.
if ($c == '"') $inQuote = !$inQuote;
// default action is to accept this element, however we have
// to check it against the list of elements to ignore, like
foreach($this->ignoreList as $ignore) {
if (preg_match(" /$ignore/" , $this->getElement ())) $break = false;
// break the while loop if this is an acceptable element
public function ignore ($str)
// add $str to ignore list
$this->ignoreList[] = $str;
public function getElement ()
return trim($this->element);
public function getEnclosed ()
public function getElementAttribute ($name)
$el = $this->getElement ();
preg_match('/[ ]+'. $name. '[ ]*=[ ]*"([^"]*)"/', $el, $result);
public function getElementName ()
preg_match("/^([^ ]*).*$/", $this->getElement (), $result);
Documentation generated on Mon, 11 Mar 2019 13:55:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|