PHP: XMLReader->read() - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

XMLReader->setParserProperty() XMLReader->open()

Last updated: Fri, 26 Jan 2007

view this page in

# XMLReader->read()

(no version information, might be only in CVS)

XMLReader->read() -- Move to next node in document

## Описание

class XMLReader {
bool read ( void )
}

Moves cursor to the next node in the document.

## Возвращаемые значения

Возвращает `TRUE` в случае успешного завершения или `FALSE` в случае возникновения ошибки.

## Смотрите также

XMLReader->moveToElement()
XMLReader->moveToAttribute()
XMLReader->next()

add a note User Contributed Notes
XMLReader->read()
jirka at kosek dot cz
08-Feb-2006 01:01
`libxml2 contains much more useful method readString() that will read and return whole text content of element. You can call it after receiving start tag (XMLReader::ELEMENT). You can use this PHP code to emulate this method until PHP will directly call underlying libxml2 implementation.
<?php
class XMLReader2 extends XMLReader
{
function readString()
{
$depth = 1;
$text = "";
while ($this->read() && $depth != 0)
{
if (in_array($this->nodeType, array(XMLReader::TEXT, XMLReader::CDATA, XMLReader::WHITESPACE, XMLReader::SIGNIFICANT_WHITESPACE)))
$text .= $this->value;
if ($this->nodeType == XMLReader::ELEMENT) $depth++;
if ($this->nodeType == XMLReader::END_ELEMENT) $depth--;
}
return $text;
}
}
?>
Just use XMLReader2 instead of XMLReader.`
add a note
XMLReader->setParserProperty() XMLReader->open()

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST