strange DOM behaviour when using minidom

J

JoReiners

Hello, I have a really strange problem. I'm unable to figure it out on
my own.

I parse very simple xml documents, without any check for their form.
These files look very similar and are encoded in UTF-8.

Now minidom is always able to parse these files with
minidom.parse("file") .
Now when fetching I use this expression:
xmldoc.getElementsByTagName('DocNumb')[0].firstChild.data.encode('latin1')

(I know it's not beautiful but convenient. )

It always work, but sometimes it simply fails to fetch any element.
Redoing it from hand in the python console with the same file always
works.

I have no idea what the error is. I compared working and not working
files with the hex editor. I couldn't find any significant change. It's
too strange. If anybody has any clue, hint or anything, please let me
know.

Regards, Jonatan
 
J

JoReiners

Sorry, I just found the error. Simple an empty attribute. Python showed
me strange row numbers. I used a multi line initialization of a dict.
The error always appeared on the first line although I was on an other
line.

Interesting behavior.

Jonatan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top