It's important to remember that when dealing with SGML, XML, HTML and other "stream" methods of storage, that there really is only one line of data there. It may be visually separated by newlines in your editor or viewer to look like separate "lines", but there really is only one line.
I think what you want to do is count how many ^ to $ you have, ignoring /^\s*<!-- .*?-->\s*$/ and pure blank lines, /^\s*$/;, and report the result. That shouldn't be that hard at all.
Comment on Re: How to count lines of code for XML file?