Web lists-archives.com

[PHP] Re: Counting File Lines in XMLReader with a Large File




On 30.08.2017 at 19:18, Alan Feuerbacher wrote:

> As part of my debugging process, I used the function LineNumber =
> $reader->expand()->getLineNo(); (after doing $reader->open(
> "InputFileName" ); ) to get the file line number that the XMLReader
> cursor was pointing to. Eventually I found that files larger than about
> 65535 lines returned wrong line numbers. Again after some online
> searching, I found a discussion from about 2006 between a PHP user and a
> developer that pretty much explained what was going on: the XMLReader
> program uses a 16-bit integer to count file line numbers, which of
> course is limited to 65535. The developer said he would not fix this,
> for various reasons.

See <https://bugs.php.net/bug.php?id=54138> for a more recent discussion.

TL;DR: You can pass LIBXML_BIGLINES
(<http://php.net/manual/en/libxml.constants.php#constant.libxml-biglines>)
as $options to XMLReader::open(), if you're using PHP ≥ 7.0.0 and libxml
≥ 2.9.0.

-- 
Christoph M. Becker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php