public static function dump(XMLReader $reader, $return = FALSE)
    {
        $node = new self($reader);

        $nodeType = $reader->nodeType;
        $nodeName = $node->getNodeTypeName();

        $extra = '';

        if ($reader->nodeType === XMLReader::ELEMENT) {
            $extra = '<' . $reader->name . '> ';
            $extra .= sprintf("(isEmptyElement: %s) ", $reader->isEmptyElement ? 'Yes' : 'No');
        }

        if ($reader->nodeType === XMLReader::END_ELEMENT) {
            $extra = '</' . $reader->name . '> ';
        }

        if ($reader->nodeType === XMLReader::ATTRIBUTE) {
            $str = $reader->value;
            $len = strlen($str);
            if ($len > 20) {
                $str = substr($str, 0, 17) . '...';
            }
            $str   = strtr($str, array("\n" => '\n'));
            $extra = sprintf('%s = (%d) "%s" ', $reader->name, strlen($str), $str);
        }

        if ($reader->nodeType === XMLReader::TEXT || $reader->nodeType === XMLReader::WHITESPACE || $reader->nodeType === XMLReader::SIGNIFICANT_WHITESPACE) {
            $str = $reader->readString();
            $len = strlen($str);
            if ($len > 20) {
                $str = substr($str, 0, 17) . '...';
            }
            $str   = strtr($str, array("\n" => '\n'));
            $extra = sprintf('(%d) "%s" ', strlen($str), $str);
        }

        $label = sprintf("(#%d) %s %s", $nodeType, $nodeName, $extra);

        if ($return) {
            return $label;
        }

        printf("%s%s\n", str_repeat('  ', $reader->depth), $label);

        return null;
    }
public static function dump(XMLReader $reader, $return = FALSE)
    {
        $node = new self($reader);

        $nodeType = $reader->nodeType;
        $nodeName = $node->getNodeTypeName();

        $extra = '';

        if ($reader->nodeType === XMLReader::ELEMENT) {
            $extra = '<' . $reader->name . '> ';
            $extra .= sprintf("(isEmptyElement: %s) ", $reader->isEmptyElement ? 'Yes' : 'No');
        }

        if ($reader->nodeType === XMLReader::END_ELEMENT) {
            $extra = '</' . $reader->name . '> ';
        }

        if ($reader->nodeType === XMLReader::ATTRIBUTE) {
            $str = $reader->value;
            $len = strlen($str);
            if ($len > 20) {
                $str = substr($str, 0, 17) . '...';
            }
            $str   = strtr($str, array("\n" => '\n'));
            $extra = sprintf('%s = (%d) "%s" ', $reader->name, strlen($str), $str);
        }

        if ($reader->nodeType === XMLReader::TEXT || $reader->nodeType === XMLReader::WHITESPACE || $reader->nodeType === XMLReader::SIGNIFICANT_WHITESPACE) {
            $str = $reader->readString();
            $len = strlen($str);
            if ($len > 20) {
                $str = substr($str, 0, 17) . '...';
            }
            $str   = strtr($str, array("\n" => '\n'));
            $extra = sprintf('(%d) "%s" ', strlen($str), $str);
        }

        $label = sprintf("(#%d) %s %s", $nodeType, $nodeName, $extra);

        if ($return) {
            return $label;
        }

        printf("%s%s\n", str_repeat('  ', $reader->depth), $label);

        return null;
    }
public static function dump ( XMLReader $ reader , $ return = FALSE ) { $ node = new self ( $ reader ) ; $ nodeType = $ reader -> nodeType ; $ nodeName = $ node -> getNodeTypeName ( ) ; $ extra = '' ; if ( $ reader -> nodeType === XMLReader :: ELEMENT ) { $ extra = '<' . $ reader -> name . '> ' ; $ extra .= sprintf ( "(isEmptyElement: %s) " , $ reader -> isEmptyElement ? 'Yes' : 'No' ) ; } if ( $ reader -> nodeType === XMLReader :: END_ELEMENT ) { $ extra = '</' . $ reader -> name . '> ' ; } if ( $ reader -> nodeType === XMLReader :: ATTRIBUTE ) { $ str = $ reader -> value ; $ len = strlen ( $ str ) ; if ( $ len > 20 ) { $ str = substr ( $ str , 0 , 17 ) . '...' ; } $ str = strtr ( $ str , array ( "\n" => '\n' ) ) ; $ extra = sprintf ( '%s = (%d) "%s" ' , $ reader -> name , strlen ( $ str ) , $ str ) ; } if ( $ reader -> nodeType === XMLReader :: TEXT || $ reader -> nodeType === XMLReader :: WHITESPACE || $ reader -> nodeType === XMLReader :: SIGNIFICANT_WHITESPACE ) { $ str = $ reader -> readString ( ) ; $ len = strlen ( $ str ) ; if ( $ len > 20 ) { $ str = substr ( $ str , 0 , 17 ) . '...' ; } $ str = strtr ( $ str , array ( "\n" => '\n' ) ) ; $ extra = sprintf ( '(%d) "%s" ' , strlen ( $ str ) , $ str ) ; } $ label = sprintf ( "(#%d) %s %s" , $ nodeType , $ nodeName , $ extra ) ; if ( $ return ) { return $ label ; } printf ( "%s%s\n" , str_repeat ( '  ' , $ reader -> depth ) , $ label ) ; return null ; }
debug utility method

@param XMLReader $reader
@param bool $return (optional) prints by default but can return string
@return string|null
debug utility method