Unfortunately, I can't find any way to get the current position in the
file when using ParseFile. I know that if expat throws an ExpatError,
that will contain the line and column number, but that doesn't help me
in this situation, as the file is 'well formed' XML as far as expat is
concerned.
So is there any way to ask the expat parser where it is in the file?
Even a byte offset from the beginning of the file would be better than
nothing.
--
C. Laurence Gonsalves "Any sufficiently advanced
clgo...@kami.com technology is indistinguishable
http://cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke
I'm pretty sure ErrorColumnNumber, ErrorLineNumber, and ErrorByteIndex are
updated even when there is no error.
Van
You're right, they do seem to get updated continuously. I didn't even
try checking this because the documentation explicitly says these values
won't be valid unless the parser raises an xml.parsers.expat.ExpatError
exception.
ie, http://python.org/doc/current/lib/xmlparser-objects.html says:
The following attributes contain values relating to the most recent
error encountered by an xmlparser object, and will only have correct
values once a call to Parse() or ParseFile() has raised a
xml.parsers.expat.ExpatError exception.
ErrorByteIndex
Byte index at which an error occurred.
...
ErrorColumnNumber
Column number at which an error occurred.
ErrorLineNumber
Line number at which an error occurred.
So is this an error in the documentation, or is the fact that these
values are continuousy updated merely a "quirk" in the current behaviour
that I shouldn't rely on because it may change at some point in the
future?
I'd be much happier if the docs didn't say that I can't do what I want
to do...
Then it might perhaps be good to document and "nail it
down", so that other components may reliably depend
on it just as well...
Alex