note 102770 added to domnode.getlineno

From: Date: Sat, 05 Mar 2011 02:28:08 +0000
Subject: note 102770 added to domnode.getlineno
Groups: php.notes 
Request: Send a blank email to php-notes+get-177573@lists.php.net to get a copy of this message
This function is buggy. It doesn't always return the correct line number, especially for text elements. As an alternative you can do something like this: <?php $text = $node->ownerDocument->saveXML($node); $line += substr_count($text, "\n"); ?> You'll want to keep a reference to $line (starting at 0) and add to it as you parse over the document recursively. In order for this to work you have to tell DOMDocument to preserve white space before loading the document. ---- Server IP: 192.41.42.26 Probable Submitter: 74.93.181.202 ---- Manual Page -- http://www.php.net/manual/en/domnode.getlineno.php Edit -- https://master.php.net/note/edit/102770 Del: integrated -- https://master.php.net/note/delete/102770/integrated Del: useless -- https://master.php.net/note/delete/102770/useless Del: bad code -- https://master.php.net/note/delete/102770/bad+code Del: spam -- https://master.php.net/note/delete/102770/spam Del: non-english -- https://master.php.net/note/delete/102770/non-english Del: in docs -- https://master.php.net/note/delete/102770/in+docs Del: other reasons-- https://master.php.net/note/delete/102770 Reject -- https://master.php.net/note/reject/102770 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177573) next »