note 102771 added to domnode.getlineno

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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/102771
Del: integrated  -- https://master.php.net/note/delete/102771/integrated
Del: useless     -- https://master.php.net/note/delete/102771/useless
Del: bad code    -- https://master.php.net/note/delete/102771/bad+code
Del: spam        -- https://master.php.net/note/delete/102771/spam
Del: non-english -- https://master.php.net/note/delete/102771/non-english
Del: in docs     -- https://master.php.net/note/delete/102771/in+docs
Del: other reasons-- https://master.php.net/note/delete/102771
Reject      -- https://master.php.net/note/reject/102771
Search      -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.