Re: Counting File Lines in XMLReader with a Large File

From: Date: Wed, 30 Aug 2017 22:08:29 +0000
Subject: Re: Counting File Lines in XMLReader with a Large File
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-326193@lists.php.net to get a copy of this message
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

« previous php.general (#326193) next »