document example

public function parse($input, array $options = array())
    {
        $this->errors = array();
        $options = array_merge($this->defaultOptions, $options);
        $events = new DOMTreeBuilder(false, $options);
        $scanner = new Scanner($input, !empty($options['encoding']) ? $options['encoding'] : 'UTF-8');
        $parser = new Tokenizer($scanner$events, !empty($options['xmlNamespaces']) ? Tokenizer::CONFORMANT_XML : Tokenizer::CONFORMANT_HTML);

        $parser->parse();
        $this->errors = $events->getErrors();

        return $events->document();
    }

    /** * Parse an input stream where the stream is a fragment. * * Lower-level loading function. This requires an input stream instead * of a string, file, or resource. * * @param string $input The input data to parse in the form of a string. * @param array $options An array of options. * * @return \DOMDocumentFragment */
$this->rules->setTraverser($this);
    }

    /** * Tell the traverser to walk the DOM. * * @return resource $out Returns the output stream. */
    public function walk()
    {
        if ($this->dom instanceof \DOMDocument) {
            $this->rules->document($this->dom);
        } elseif ($this->dom instanceof \DOMDocumentFragment) {
            // Document fragments are a special case. Only the children need to             // be serialized.             if ($this->dom->hasChildNodes()) {
                $this->children($this->dom->childNodes);
            }
        }        // If NodeList, loop         elseif ($this->dom instanceof \DOMNodeList) {
            // If this is a NodeList of DOMDocuments this will not work.             $this->children($this->dom);
        }         // Else assume this is a DOMNode-like datastructure.
Home | Imprint | This part of the site doesn't use cookies.