minidom help -- line number

GZ zyzhu2000 at gmail.com
Sat Aug 14 13:40:13 EDT 2010


On Aug 14, 12:07 pm, Thomas Jollans <tho... at jollybox.de> wrote:
> On Saturday 14 August 2010, it occurred to GZ to exclaim:
>
> > Hi All,
>
> > I am writing a little program that reads the minidom tree built from
> > an xml file. I would like to print out the line number of the xml file
> > on the parts of the tree that are not valid. But I do not seem to find
> > a way to correspond minidom nodes to line numbers.
>
> The DOM does not contain things like line number information. You work with
> the structure of the document, not the appearance of the file you happen to be
> using as a source. You can't use line numbers with minidom.
>
> For stream-based parsers like SAX and eXpat (both in the standard library)
> this makes more sense, and they both allow you to check the current line
> number in one way or another.

So I am basically out of luck if I want to tie back to the original
file for file error reporting etc. sounds like a deficiency to me.



More information about the Python-list mailing list